Closed Thread Icon

Topic awaiting preservation: imageMagick tips (Page 1 of 1) Pages that link to <a href="" title="Pages that link to Topic awaiting preservation: imageMagick tips (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: imageMagick tips <span class="small">(Page 1 of 1)</span>\

Paranoid (IV) Inmate

From: Dallas, TX
Insane since: Aug 2002

posted posted 09-06-2002 11:57

So I've just started using imageMagick to do something similar to images as what the Doc did with his recent script.
And I've found some things that don't sit well with me, but can be worked around.
So here are some tips and info i've found.

When converting and resizing a gif to png, and perhaps other formats as well, imageMagick likes to change the color depth to a higher number of colors.
I assume it does this in order to give the best looking output for the size, but usually when making thumbnails you don't really want a filesize larger than the original's.
So when I was converting 64color 28k gifs to 115px pngs
$ convert -size 115 /html/images/image.gif -resize 115 /html/images/image.png

i was getting a 32k filesize. That's just bad juju.
imageMagick was changing the color depth to 32bit. yipe.
So you wanna keep the color depth, using -colors . . .
$ convert -size 115 /html/images/image.gif -colors 64 -resize 115 /html/images/image.png

This way i got like a 7.4k png. much better.

This does present problems though.
You might have varying gifs with varying color depths and you can't always standardize.
This may not be any big deal as thumbnails aren't usually color intensive, but still.
The only way I can think to counteract this in PHP is to use
$colors = imagecolorstotal(myimage)

this requires GD be compiled with php. Although I read GD can't detect colordepths past 128 until its v2.
Then you can put...
$rawImg = "/bin/convert -size 115 /html/images/image.gif -colors $colors -resize 115 png:-"

Or some similar exec.

Please post any tips or warnings if you got any.

Paranoid (IV) Inmate

From: Dallas, TX
Insane since: Aug 2002

posted posted 09-06-2002 14:54

also if you have transparency in your gif you want carried over to your png...
due to IE's horrible handling of png transparency (even with the DirectX filter hack) you'll want to resize the gif and then mogrify to png, like this ...

$ convert -size 110 /images/image.gif -colors 64 -resize 110 /images/image2.gif

$ mogrify -format png /images/image2.gif

this leaves you with the transparency like it was in the gif and displays right in IE.... i don't know why.

« BackwardsOnwards »

Show Forum Drop Down Menu