Is there anything in the API for getting image optimization into a preset? Most of the users who upload to image galleries don't have photoshop so just upload raw images. I have a "display" preset to scale inside dimensions to 640px. Without optimization the images are in the 300-400k range -- when I save-for-web in photoshop as 60-quality jpegs they end up in the 50k range.

many thanks ...

Comments

guidot’s picture

I don't know about imagecache-specific ways to do this, but if you are ok with one setting for all images, you can set the jpeg quality at http://example.com/index.php?q=admin/settings/image-toolkit

bogdrupal’s picture

yep, that will work, thanks

guidot’s picture

Category: feature » support
Status: Active » Fixed
dopry’s picture

Version: 5.x-1.5 » 6.x-2.x-dev
Category: support » feature
Status: Fixed » Active

I would be totally cool to have a 'generic' convert action that allows you to adjust quality and format... I'm making this a feature request.

MisterSpeed’s picture

There are a few possibilities here; one would be a heuristic approach that reduces the quality of images until a certain maximum size (in kilobytes) is reached; the other would simply be an override of the generic image-toolkit settings only for the use of that module; a third is as proposed in the ticket intro: to constrain the resulting dimensions to a maximum bounding box. Which of these would users of the module find valuable ?

MisterSpeed’s picture

Guidance on this from the OP or the commentators would be much appreciated !

xalexas’s picture

Can somebody tell my why imagecache resamples images with applied scale action even if scaling is not necessary (image is smaller than scale dimension)? I have set image quality in image-toolkit to 100% but without any effect. I know i can put original images without scaling but i need scaling limit just in case if user upload bigger image than allowed.

smitty’s picture

Does anybody know additional opportunities to optimize the images?

I'm using ImageCache and the Image Module and the thumbnails created by them get 28kb (109x109 pixels; Compression Quality: 75%). If I use 'save-for-web' in Photoshop (75% quality) they get only 5kb.

Changing the 'Compression Quality' in the ImageAPI has almost no effect. With only 10% quality the thumbnails get pretty ugly but they are still 26kb.

lop’s picture

You can get the lowest filesize by removing all metadata (Exif, IPTC, XMP, ICC profile, embedded thumbnail) from images. And that is exactly what Photoshop's 'save-for-web' function is doing.

Unfortunately there is no ImageCache/ImageAPI action at this time to handle this.
But you can use ImageMagick raw action module to make a new ImageCache action with a simple command line option: -strip and add it as a last action in a preset.

Note: The -strip command line option is supported by IM 6.x only. For older versions you can try command: +profile "*"

Scott J’s picture

I think everything that you want is in 'ImageMagick Advanced Options' module - see http://groups.drupal.org/node/6699. It comes with, but is not dependent on, Image module, but works great for ImageCache as well. If you don't need the rest of Image module, this can be enabled by itself.

Your images will thank you for it........

Scott J’s picture

I just tried moving the
/sites/all/modules/image/contrib/image_im_advanced
folder to
/sites/all/modules/image_im_advanced/
and it seems to be happy all by itself, so that you don't have unnecessary modules cluttering your site.

smitty’s picture

Thanks a lot for these hints!

ImageMagick raw action works perfectly for me.

I also tried the 'ImageMagick Advanced Options' module. But this module did nothing for me. I think the 'reason why' is: This module is connected to the Image Toolkit. But ImageCache uses the ImageApi module. So Probably it is never called while ImagaCache is doing its work for the image module via the "ImageCache 4 Image" module in Drupal 5.

Scott J’s picture

Maintainer Wanted
I asked the Image project team at http://drupal.org/node/735498 , but it turns out that "ImageMagick Advanced Options" module is an old project that has been through several pairs of hands, and the current maintainer knows nothing whatsoever about ImageMagick.

Further, he states that "If anyone wants to volunteer to maintain that particular module, that would be fantastic. I'm open to suggestions for moving it to ImageAPI too."

So, if anyone would like to try improving "ImageMagick Advanced Options", it's all yours.

jcisio’s picture

This is an old topic. But...

I use ImageMagick/ImageAPI for Imagecache. On ?q=/admin/settings/imageapi/config I have compression quality 75%, the version is:

Version: ImageMagick 6.4.8 2009-11-27 Q16 OpenMP http://www.imagemagick.org
Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC

The original image is
http://ms.thongtincongnghe.com/files/images/2010/3/11/lenovoideapads10-3... (130 KB, ok)

I use Imagecache to resize (action: scale, option: 216x72):
http://ms.thongtincongnghe.com/files/imagecache/gallery/images/2010/3/11... (13 KB)

When I ssh to the server, run the command:
convert path/to/src -thumbnail 216x72 -quality 75% lenovoideapads10-3tgal44.jpg.jpg

I have this:
http://ms.thongtincongnghe.com/files/imagecache/gallery/images/2010/3/11... (2.4 KB, only!)

When I try with 80%, I have 2.7 KB. All that mean that Imagecache result is far from optimal.

May we need a patch for the core ImageAPI ?

jcisio’s picture

Status: Active » Fixed

Just look into the ImageAPI and found it. On the last stable version (6.x-1.6), I need to modify line 117, replace -resize by -thumbnail. It will fix the problem with my latest Imagemagick binary.

Issue submitted for ImageAPI: #740476: Use -thumbnail instead of -resize

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.