Page 1 of 1

Problem with Jpeg Quality

Posted: 2014-08-19T07:06:47-07:00
by ColonelFender
Hi,

I'm experimenting with ImageMagick for re-sizing and compressing JPGs on my webserver. Getting the best file-size/quality is really important for this project.

My test image seems to be poor quality when saved from ImageMagick compared to other programs, for the same file size.

I've put some example files here:

https://www.dropbox.com/sh/87gxp9f1r517 ... G2zeUk2T4a

I re-sized and compressed the large Original.jpg with ImageMagick 6.8.9-6 Q16 Windows with the command:

convert Original.jpg -resize 640x640 -quality 35 ImageMagick.jpg

and got a file that's about 39k.

I did the same with PaintShopPro 5 - using a quality of 20 to get the same filesize.

As you can see there's a lot more banding in the sky in the ImageMagick version - and a lot more jpeg artefacts round the building.

The ImageMagick re-size seems good - I think the problem is with the jpeg compression.
As there are so many settings, I was wondering if there's something else I should try to get a better result.

Thanks for any help

Re: Problem with Jpeg Quality

Posted: 2014-08-19T07:33:03-07:00
by Bonzo
I would try this and see what you get:

Code: Select all

convert Original.jpg -thumbnail 640x640 -quality 100 ImageMagick.jpg

Re: Problem with Jpeg Quality

Posted: 2014-08-19T08:00:08-07:00
by ColonelFender
Yes - that looks better - but it's 239k! I'm trying to get better quality at the same file size.

Re: Problem with Jpeg Quality

Posted: 2014-08-19T09:03:15-07:00
by Bonzo
Out of interest what file size do you have if you use -quality 70 now?

Re: Problem with Jpeg Quality

Posted: 2014-08-19T13:04:04-07:00
by ColonelFender
-70 gives a filesize of 52k. Quality is not far behind the PSP version - but obviously that's a big difference in filesize if you're preparing images for the web. (I guess for a lot of other purposes it doesn't really matter that much).

Just wondered if it was something I'm doing wrong...

Re: Problem with Jpeg Quality

Posted: 2014-08-19T13:23:49-07:00
by Bonzo
You might do better with a different filter but you would have to change it for each image. A bit of -unsharp might help but it would not cure the banding.

Re: Problem with Jpeg Quality

Posted: 2014-08-19T14:00:48-07:00
by glennrp
Be sure you haven't got a large amount of metadata in the file. That is usually the cause of surprisingly large JPEG outputs. Your Original.jpeg has at least

Profiles:
Profile-exif: 13820 bytes
Profile-xmp: 3965 bytes

Re: Problem with Jpeg Quality

Posted: 2014-08-19T17:36:49-07:00
by ColonelFender
Yeah - that was it: adding a -strip to my command line has got rid of the extra file size.

Thanks very much glennrp.

Re: Problem with Jpeg Quality

Posted: 2014-08-20T01:31:52-07:00
by Bonzo
You have also lost your colour profile now.

Re: Problem with Jpeg Quality

Posted: 2014-08-20T06:42:31-07:00
by glennrp
Bonzo wrote:You have also lost your colour profile now.
But "Original.jpg" doesn't have a colour profile. All it has is a "Colorspace 1" entry inside the EXIF data, which means sRGB. Currently ImageMagick is assuming sRGB anyhow. Note that with the current IM6, "convert Original.jpg Original.png" inserts the sRGB chunk, gAMA 1/2.2, and the cHRM chunk containing sRGB chromaticities into the PNG file. These chunks also appear in the PNG file if you strip the JPEG first: "convert Original.jpg -strip Stripped.jpg; convert Stripped.jpg Stripped.png"