Image compression / JPEG Quality

mrfelton's picture

There seem to be two places where I can set the 'JPEG quality' of uploaded images:


So, question 1) What does each setting do - why are there 2 settings? As far as I can make out, the imageapi setting affects imagefield and imagecache, whilst the other setting effects other uploaded images.

2) More importantly... How can I disable automatic compression of images? I don't want Drupal screwing with my uploaded images. I have spent time and effort compressing my images exactly the way I want them, to optimise the quality and filesize to my needs. However, when I upload one of these images via a cck imagefield, they get compressed again, and either the quality or filesize is completely messed up.

I have tried setting the 'jpeg quality' to 0 or 100%, neither of which disable the compression. with it set to 0, I get the most blocky looking images on the planet. With it set to 100%, I can't see any change in the quality of the images, but the filesize increases massively - 3 or 4 times in some cases.

The best I have found so far is to set it top about 95%, where I see only a small change in filesize and quality. This is less than ideal. Is there really no way to disable image tampering? I think that users really should be able to decide for themselves if they want Drupal interfering or not.


Good topic

corbacho's picture

Also I heard Imagemagick makes a better work than GD, specially in resizing, but didn't try still. Someone?

I would also like to know if

pog21's picture

I would also like to know if there is a way of turning off the compression. For user-uploaded images, I'm happy to use a single compression setting. But I optimise many of the images on my site individually because they require different amounts of compression. It does not make sense for these to be re-compressed by drupal or to be made huge again by using near-100% quality.
I've seen some people mention imagemagick in relation to the general quality of compression, but many don't have access to server to use it. Would be better just to be able to switch it off.
Perhaps best of all would be to have an option within the image-cache presets to use compression or not.

Good questions

astro87's picture

Somone know how to disable automatic compression of images? I also don't want Drupal to change my uploaded images in some cases.

Drupal doesn't recompress on upload

David D's picture

I do not believe either of these settings affect uploaded images at all. They only come into play when new versions of images are created by imagecache or the like, and in that circumstance there must be such a setting, just as there is at any time you are generate jpegs with any tool. To test this, I just uploaded a jpeg that was 1,466,368 bytes to a CCK Imagefield field. It remained exactly the same size on the server. The displayed image on the node was indeed different, but that's because I have imagecache set up to display it in a different size. That's all as it is supposed to be.

Monte Hayward's picture

My test image was 1000 x 1571 pixels. Perhaps because of width constraints in my theme, the image was 720 x 1131 pixels, after upload. This is not re-sizing in the HTML attributes; the actual size was changed. Because JPEG is lossy, the image then looked awful. It had a subtle gradient and headline type, which took on exaggerated artifacts.

I'm not sure where the constraint is set. The image size would have exceeded the CSS rule for the main content area:
.sidebar-first #content {
width: 760px;
margin-left: 200px;
margin-right: -960px;

I then shrank the image dimensions to 720x1131, and uploaded again.
The dimensions saved by Drupal were the same, but the artifacts look like moon craters. The image went from 168K to 55K.

This post was of type "Comic", using module Comicdrop.

In my case, the image has a configuration under Comicdrop:

In the more general case, image scaling is configured here:

That being said, it still re-compressed the image newly uploaded.

A couple of things to check

David D's picture

@Monte Hayward, on my sites I have never seen the kind of major artifacts in any Drupal-scaled jpegs that you describe. In D7, I usually have admin/config/media/image-toolkit set to 75%.

To eliminate the chance that this is anything that your browser is contributing, if you right-click the image and "Open image in new tab,", you'll see the true image in that tab, without any chance of html scaling.

To see what image styles may be getting applied to your image, there are a couple of ways to check. At admin/structure/types/manage/content_type_machine_name/display (that's the Manage Display tab of , check the Node image style for the field in question. If it is anything other than None (original image), then that's where the scaling is coming from.

You can also just do an "inspect element" (that's Chrome's language for it) on the image as it is displaying on your site. The path in the source code for the image will tell you if an image style is applied to it. Specifics depend on how you've configured things, but the source will show something like if the image was generated from a style setting.

Drupal resizes your images

jcisio's picture

Drupal resizes your images because you tells it to do so (it is in the field widget settings). If you don't want Drupal to resize images, either increase the dimension limits or resize images before uploading them.

Or just increase the image quality settings, use imagemagick and a few optimization tricks. A useful module is, you might want to try it.

No improvement with 100% image quality

MakeOnlineShop's picture


I have tried to set all to 100% quality:


But the quality hasn't improved (I flushed).

Any help ?

Thanks a lot.

Image Quality and Size

DanNY's picture

Don't know if anyone still following, but my 2 cents.

For Quality: I noticed quality was reduced. I had already optimized my images. Changed setting under Configuration, Media, Image Toolkit. Was 80%, changed to 100%. Then they looked as they should.
Possible the additional module conflicting?

For Size: The content type may have an Image field with default settings based on theme. Change there.

Also Size and cropping: Under Config, Media, Image Styles is where the setting for resizing and cropping appears for other images.


To stop image compression you

willeaton's picture

To stop image compression you have to set both values to 100% and then reupload the images. The compression is done on uploading the file so clearing the cache does nothing because the copy of the file on the server is already compressed. The reason behind it is that most front end users of Drupal dont understand image compression and this helps to save on server space.

Still following :-)

MakeOnlineShop's picture

Thank you for your reply, but even without compression the pictures are still not very nice, I don't know why.