Ever since using 4.5 and image.module for 4.5, my uploaded images have been getting poor jpeg quality for their thumbnails. Is this because of image.module or ImageMagick? If it's the module, how do I change the jpeg quality for thumbnails?

Comments

bryan kennedy’s picture

I am looking to find some information about this as well. Does anyone have any input?

Zach Harkey’s picture

The thumbnail quality has gone way down.

: z

bryan kennedy’s picture

Since 4.6 is around the corner I don't feel like it is worth trying to get this fixed in the current image.module. However, I was able to hack a real quick solution to this problem.

  1. Open the image.inc file in the image module folder
  2. Find this code at line 282:
      if ($quality) {
        $image->trasform_string .= ' -quality ' . $quality;
      }
    
  3. Replace it with this hack :
      if ($quality) {
        $image->trasform_string .= ' -quality 100';
        //$image->trasform_string .= ' -quality ' . $quality;
      } else {
        $image->trasform_string .= ' -quality 100';
      }
    

Like I said, this is a real quick hack, but it did cause the image module to do all of my resizing appropriately at 100% quality. This significantly improved the quality of my images that I uploaded. If anyone knows of a more appropriate of efficient way to do this please post.

Note: This will not affect images you have already uploaded.

Danio’s picture

I'm still having this problem in 4.6. Anyone know how to do a hack of 4.6's image.module to fix this?

tinycg’s picture

I've noticed the same problem, really poor image quality through image galleries. Original image is fine, but the image it uses first is crap.

Does anyone know of a way to get it to use the original image first and foremost over anything else?

bryan kennedy’s picture

Alrighty, so I did another quick hack to the image.module to get some higher quality images. I am, going to try and see if I can write this into the module and get it submitted but who knows. I just went into the image.imagemagick.inc file that you had to move to you includes folder and add some flags to set the quality to 100.

So at line 29:

  $filter = ' -quality 100 -scale '. $width . 'x' . $height . ' -filter QUADRATIC';

and at line 37:

  $filter = ' -quality 100 -rotate ' . escapeshellarg($degrees) . ' -background #000000';

and then at line 45:

  $filter = ' -quality 100 -crop ' . $width . 'x' . $height . '+' . $x . '+' . $y;

And all the images I uploaded after that were nice and crisp. While a little bigger in file size. Hope this helps, at least temp.


bryan kennnedy
Help us to improve Drupal's documentation. Join the Dupal Documentation Mailing List
Danio’s picture

Thanks Bryan. I just made those changes and uploaded some images, but I'm still getting low quality. Very weird.

I put on Gallery last night and when I upload images with that, they look fine.

nurlan-1’s picture

are theese hacks for imagemagick tool? i suppose they won't have any effect if one use GD2? I can't check this out by myself, cause somehow in my drupal 4.6.1 imagemagick doesn't want find /usr/bin/convert while drupal 4.5.2 finds it without any troubles...

so, finally, what should we do? :) OOh blue sky help us...

sepeck’s picture

See this comment for how to enable image majick on your install
http://drupal.org/node/20844#comment-38700

-sp
---------
Test site...always start with a test site.
Drupal Best Practices Guide

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide

dbenton’s picture

I would recommend that anyone making the changes in this thread consider using a lower quality than 100; 100 is just not very practical. A more reasonable quality for general use would be between around 75. For photography showcases and the like, use 100.

For further tweaking info, see http://drupal.org/node/29528.

nurlan-1’s picture

make this hack to your image.inc which is located in your includes directory:

find 223 line where
$result = image_gd_close($res, $destination, $info['extension']);

and replace it with
$result = imagejpeg($res, $destination, '100');

it will help you, i hope :). It worked for me.

dream77’s picture

the result got better, but not god enuff. I am a photagrapher so this is kind og enoying. Anyone that can fix this? I myself do not have the knowledge to sort this kind of problem. It seems to work on small picktures, but not on large ones.

Please help me.