'convert -sample' same settings, diferent image sizes..

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
nahual

'convert -sample' same settings, diferent image sizes..

Post by nahual »

Hi, I'm using the following line to resize uploaded images to my forum:

Code: Select all

$exit_code = system("convert -sample 600x600\\> $savedfile $savedfile");
Using that line i was able to convert an image of more tha 2000k to one of 142k:
http://www.fororeptiles.org/cgi-bin/for ... 181782722/
this host is using IM 6.2.5 version.

then using that line again but at another server I was able to convert that same image to a very convenient 52K!!!
http://www.bajapesca.net/cgi-bin/forum/ ... 181782114/
this server is using IM 5.x.x version.

Could this be an imagemagick version related issue?
As you can see quality is about the same but the 6.2.5 conversion is about three times the size of the 5.x
If the above is true, Is it there any way to make new version behave as the old one??
142k stills very good for the web, but my forum is intended for mexican users and a lot of them uses dial up conections :( .
Thank you very much for your time..

Luis Larios
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: 'convert -sample' same settings, diferent image sizes..

Post by anthony »

More than likely the newer one preserved profiles...

Add a -strip or replace the -sample with -thumbnail to remove the profiles.
Thumbanils is a little slower but generally faster than resize to produce a better quality image.
-thumbnail
Resize and strip the image of any format specific 'fluff'.

It is designed specifically for shrinking very very large images to
small thumbnails. First it -strips all profile and other fluff from
image, then -samples the image down to 5 times the final height,
before running an normal -resize to reduce the image to its final
size.

This can speed up up the thumbnail generation by quite an amount. For
thumbnails of JPEG images, you can limit the size of the image read in
from disk using the "-size" setting, so the extra speed improvement
is rarely needed for JPEG in thumbnail generation.
For more info see IM Examples, thumbnailing...
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
nahual

Re: 'convert -sample' same settings, diferent image sizes..

Post by nahual »

Usign the -thumbnail feature i was able to generate an image that is a little bit smaller that the one I'm getting with the -strip -sample in 6.2.5 version. As you said the quality also improved! ***thanks****. Unfortunaly I havent been able to end with an image less than 100k as the -sample in 5.x version does?
Anything else to try???
Thanks again for you time an fast reply..
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: 'convert -sample' same settings, diferent image sizes..

Post by anthony »

The other thing is that the IM attempts to preserve the 'presumed' compression quality of the input JPEG image. You may need to just set a -quality 75 or something like to settle the issue.

identify should be able to tell you what 'quality' IM thinks the image was saved using.

WARNING: -quality is format specific option. It means something different for PNG than it does to JPEG. See IM exmaples, Common Formats for more specifc info.

Another options effecting image outcome is -compression and format specific -defines. however the problem with -define is that there are quite a number of them but few are documented.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
nahual

Re: 'convert -sample' same settings, diferent image sizes..

Post by nahual »

Thank you very much for your help. Setting the -quality, as you said, did the trick:

Code: Select all

$exit_code = system("convert -quality 90 -thumbnail 600x600\\> $savedfile $savedfile");
-sample and -quality do not got along very good as images always ended with bad looking edges
Using -thumbnail and -quality, i was able to generate very good quality images with low file sizes.

**thanks for your help**
Post Reply