hi !

I use Imegecache & CCK imagefield. I'd like to display multiple size square images in my nodes. It seems to work fine, but the image quality after resize is really crappy :(

I use imagemagick so I don't understand why... Do you ?

Furthermore, do you know how I can have square cropped images with imagecache ?

Thank you.

Comments

Anonymous’s picture

More details and tests feedbacks here ;)
http://drupal.org/node/103446/

Anonymous’s picture

Priority: Normal » Critical
FiReaNGeL’s picture

I agree - just trying imagecache right now, and its very useful, except for the awful quality of scaled pictures. I mean, it's like jpeg quality 20 or something. I'd love to have an option to set quality!

FiReaNGeL’s picture

Title: Uggly image resize & crop » Ugly image resize & crop in image.inc with GD
Project: ImageCache » Drupal core
Version: 4.7.x-1.x-dev » 5.x-dev
Component: Code » base system
Category: support » feature
Priority: Critical » Normal

Ok, tracked down the source of this problem down to image.inc, so its not an imagecache / imagefield problem.

in function image_gd_close($res, $destination, $extension), the imagejpeg() function (in the case of a jpg file) takes only 2 arguments. In the documentation (http://ca.php.net/function.imagejpeg), there`s a third parameter for quality; if its omitted, a value of 75 is used (which as we saw, is pretty ugly looking).

We should patch image.inc to allow for custom quality jpeg settings.

In the meantime, I just use :

function image_gd_close($res, $destination, $extension) {
  $extension = str_replace('jpg', 'jpeg', $extension);
  $close_func = 'image'. $extension;
  if (!function_exists($close_func)) {
    return FALSE;
  }
  if($extension == 'jpeg')
  {  return $close_func($res, $destination, 100); }
  else
  return $close_func($res, $destination);
}

Anyone have the necessary knowledge to patch image.inc?

FiReaNGeL’s picture

Also, the original bug reporter said that he was using imagemagick, so its not only GD. My solution is only against GD, but Im sure it will be very similar for imagemagick.

sime’s picture

Title: Ugly image resize & crop in image.inc with GD » only 75% jpg quality - image.inc with GD

/subscribed. I recently hacked this into an installation. Better description.

Anonymous’s picture

Indeed, I use imagemagick but I don't know how to patch the function... My php knowledges are too bad but your explanation is really interesting :)

FiReaNGeL’s picture

Status: Active » Closed (duplicate)