Wednesday, March 26, 2008

magick... magick... everywhere...

Recently I had a problem while converting a 'png' image into 'jpeg' format. I was using Imagemagick (mogrify command line tool) for this. I used the following command:

%mogrify -format jpg pic.png

Converted 'jpeg' image was totally different from the original 'png' image. Some area of the converted 'jpeg' image was coming black instead of white in the original one.



Then I tried the same thing using GIMP, and I came to know that 'png' format supports layers. So flattening is needed before converting a 'png' image into 'jpeg' because later one does not support layers. So I tried converting the image using following parameters and the result was as good as I wanted it to be :).

%mogrify -format jpg -layers flatten pic.png

2 comments:

Anonymous said...

Try the -quality switch too, to control the level of compression.

Right now I see that your jpeg is still 20K. I typically use Fireworks etc. to export png's to jpeg's for my blogs etc. and it does the compression pretty well.

bhups said...

ya! but my primary concern was 'how to handle png images which contain transparencies'. Anyways thanks for pointing that out... :)