Specify maximum 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
User avatar
whugemann
Posts: 289
Joined: 2011-03-28T07:11:31-07:00
Authentication code: 8675308
Location: Münster, Germany 52°N,7.6°E

Specify maximum JPEG quality

Post by whugemann »

I see no way to specify the maximum (or minimal) JPEG quality. I often do bulk conversions of JPEG photographs, reducing their size in order to embed them in a Word document. The JPEG quality of normal photographs is something like 95%, so if I specify '-quality 90%', the bulk-converted photographs will become smaller (in addition to their reduced dimensions).

But sometimes the original quality is much lower, because the photograph were pre-processed by some software. In this case, the above mentioned option would result in a higher JEPG quality than actually needed. So I would like to have an option like '-quality <90%', denoting: if it's higher than 90%, reduce it to 90%, but if it's lower, keep it as it is, i.e. this option would work correspondingly to the options in regard to image dimensions.

But I think that at the moment there is nothing like this built into ImageMagick (?).
Wolfgang Hugemann
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Specify maximum JPEG quality

Post by snibgo »

whugemann wrote:But I think that at the moment there is nothing like this built into ImageMagick (?).
I think you are right.

You can specify a maximum size, eg -define jpeg:extent=400KB, and IM will choose the highest quality within that size. Your script could then examine the output quality. If higher than 90, the script would re-compress with "-quality=90".
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Specify maximum JPEG quality

Post by fmw42 »

If IM finds the quality in the jpg meta data, it uses it. It only uses the default 92, when it cannot find a quality in the original jpg. see http://www.imagemagick.org/script/comma ... hp#quality.

However, your suggestion is still useful.
Post Reply