user2650277 user2650277 - 2 months ago 18
Bash Question

Graphicsmagick gives higher filesize when compressing jpg

First i took lena512color.tiff amd converted it to jpg and then i ran mogrify on it with a quality of 90%.Surprising after i decrease the quality filesize is higher.What am I doing wrong here ?

gm convert lena512color.tiff lena512color.jpg # filesize = 37,043
gm mogrify -quality 90 lena512color.jpg # filesize = 58,132


By default, the output quality is set to whatever GraphicsMagick thinks the quality of the input file is. So I guess it thinks the TIFF's quality is lower than 90 and you are actually increasing the setting.

You can use the following command to see what GraphicsMagick perceives the quality of an image to be:

identify -format %Q someImage.jpg

If your aim is to limit the size of the resulting JPEG, you can use the following -define to set the target size:

convert in.jpg -define jpeg:extent=50KB out.jpg


-rw-r--r--    1 mark  staff  49802 30 Oct 12:38 out.jpg


convert a.jpg -define jpeg:extent=30KB out.jpg


-rw-r--r--    1 mark  staff  28996 30 Oct 12:38 out.jpg