Problem with Jpeg Quality

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
ColonelFender
Posts: 4
Joined: 2014-08-19T07:04:21-07:00
Authentication code: 6789

Problem with Jpeg Quality

Post 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
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Problem with Jpeg Quality

Post by Bonzo »

I would try this and see what you get:

Code: Select all

convert Original.jpg -thumbnail 640x640 -quality 100 ImageMagick.jpg
ColonelFender
Posts: 4
Joined: 2014-08-19T07:04:21-07:00
Authentication code: 6789

Re: Problem with Jpeg Quality

Post by ColonelFender »

Yes - that looks better - but it's 239k! I'm trying to get better quality at the same file size.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Problem with Jpeg Quality

Post by Bonzo »

Out of interest what file size do you have if you use -quality 70 now?
ColonelFender
Posts: 4
Joined: 2014-08-19T07:04:21-07:00
Authentication code: 6789

Re: Problem with Jpeg Quality

Post 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...
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Problem with Jpeg Quality

Post 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.
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Problem with Jpeg Quality

Post 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
ColonelFender
Posts: 4
Joined: 2014-08-19T07:04:21-07:00
Authentication code: 6789

Re: Problem with Jpeg Quality

Post 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.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Problem with Jpeg Quality

Post by Bonzo »

You have also lost your colour profile now.
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Problem with Jpeg Quality

Post 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"
Post Reply