I noticed recently that the quality of scaled images is pretty poor. The reason for this is that the built-in GD toolkit uses PHP’s default value for the JPEG image quality setting which is 75. Unfortunately, there is no way to configure it at the moment.

This patch adds a field to configure the image quality setting for JPEG images.

CommentFileSizeAuthor
image-quality.patch2.96 KBkkaefer

Comments

FiReaNGeL’s picture

Marked http://drupal.org/node/103449 as a duplicate of this, as the current issue has a patch.

kkaefer’s picture

Hmm, I searched for this issue but could only find forum posts... Either way, thanks for marking this as duplicate.

FiReaNGeL’s picture

No problem at all, the other issue is fairly recent :) I'm very glad you found time to add a 'quality' option.

Quick glance at the patch (christmas time, im at parents house with nothing to dev with) found no errors and the same solution I came up with to fix the problem, so it's a good +1 from me :)

Thanks a lot for fixing this!

dries’s picture

Status: Needs review » Needs work
-  return $close_func($res, $destination);
+  if ($extension == 'jpeg') {
+    return $close_func($res, $destination, variable_get('image_jpeg_quality', 75));
+  }
+  else {
+    return $close_func($res, $destination);
+  }

What would be the value of $close_func? I couldn't find an existing function that uses a quality setting. Please elaborate, it not clear from the code. :/ Thanks!

scroogie’s picture

Dries: $close_func is simply 'image'.$extension, so in case of jpeg its http://php.net/imagejpg which takes an optional quality parameter.

dries’s picture

Status: Needs work » Fixed

Committed to CVS HEAD. Thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)