[thelist] ImageMagick and convert

Bob Meetin ontheroad at frii.com
Wed Oct 4 09:23:01 CDT 2006

Sort of different situation, but I do just that with an upload image 
script I wrote.  I'm doing a lot of playing around with image galleries 
and slideshows which come in all shapes and sizes.  In early stages of 
uploading images I used to place them in a single directory but 
different suffix upon rename ( image.jpg, image_thumb.jpg, etc).  Then 
of course the display script would grab an image based upon the suffix.  
The directory started to get crowded so I changed to using different 
directories (orig, tn, ltn - for large thumbnail, etc).  Once this 
became ugly, I more recently added a smarter naming convention for the 
directories themselves ( 75x75, 360x270, 640x480, original, etc).  
640x480 houses both portrait and landscape images.  The query that pulls 
images to display does a check to see if L or P. 

By default gimp sets the resave quality to 85% which is pretty high.  
With Gimp the first time I 'resave' a file, if I select 100% it will 
bump up the size a small percentage.  70% is usually good enough for the 
web and makes for quite a savings in size.

However when I use ImageMagick and convert, I've seen 100% literally 
double the image, so indeed there may be some odd behavior with convert. 
I have to drop the percentage way down to realize comparable savings 
compared to gimp or photoshop.  To do a one-time save, it's a bit of a 
guessing game, but a series of if/else or a case statement can get me in 
the ballpark. This equates to what you call a filter.  

Imagemagick/convert is generally out there and available to be included 
in processing scripts, whereas gimp, photoshop, psp, etc are not.  The 
requirement, in my mind, is to be able to upload images (for clients who 
don't know or want to know how to manipulate them), offer one or several 
processing options (through the script form) which I already do, and 
copy/rename the file as necessary. Resampling the image to a smaller 
dimension works, it's just that odd re-saving behavior (over-bloating 
the size) of convert has me scratching my head.

Thanks.  -Bob

Juha Suni wrote:
> Bob Meetin wrote:
>> Juha & et,
>> Can you or anyone suggest a better approach to solving the problem of
>> site speed and over-sized images?
> Wouldn't it just be enough to resample the images to certain dimensions 
> (800x600?) and save them as 80% jpeg, for example. On average you should get 
> image sizes that are average for images that size (for the example given I 
> think we are looking at the range of about 60K to 200K).
> Lowering the jpeg-quality (which, as discussed earlier, is not as good an 
> option than one would imagine) and resampling the image to a different size 
> are pretty much the only good options for lowering the filesize. I'd stick 
> to them and make it simple. You could, of course, keep a filter in place 
> that makes sure images below 100K, for example, would never get processed 
> since they are small enough already.

More information about the thelist mailing list