disappointed by -define jpeg:preserve-settings results

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

disappointed by -define jpeg:preserve-settings results

Post by NicolasRobidoux » 2013-05-12T05:41:17-07:00

(Warning: I only looked at this quickly. Working to a tight deadline, and I'm using direct cjpeg calls because I rely on customized progressive scan scripts.)
Take the logo_sample.jpg image for example, and look at the result of

Code: Select all

convert logo_sample.jpg -resize 500x500\> -define jpeg:preserve-settings junk.jpg
With bleeding edge IM6 or IM7, compiled in HDRI or Q16, the colour is sucked out of the red letters, almost but not quite as if Chroma subsampling was turned on.
Inspecting with djpeg does not reveal anything significant.
I understand that I can't expect a "perfect" copy when sucking a JPEG into ImageMagick (note that the image is smaller than 500x500, so -resize 500x500\> is a no-op). But the size of the difference is surprising me. A lot. -define jpeg:dct-method=float does not help here.
No surprise with png.
Again: I'm not sure it's a bug. But being that far off even in HDRI mode, in IM6 and IM7 both, is surprising.
Am I missing something (besides possibly underestimating the destructive power of a JPEG toolchain)?

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: disappointed by -define jpeg:preserve-settings results

Post by NicolasRobidoux » 2013-05-12T06:08:02-07:00

Note: No need to educate me on how to use other tools than IM to do lossless JPEG manipulation: I know.

User avatar
magick
Site Admin
Posts: 11062
Joined: 2003-05-31T11:32:55-07:00

Re: disappointed by -define jpeg:preserve-settings results

Post by magick » 2013-05-12T07:20:01-07:00

We don't support a preserve-settings define. What were you expecting it to do?

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: disappointed by -define jpeg:preserve-settings results

Post by NicolasRobidoux » 2013-05-12T10:36:56-07:00

This explains a lot! I found this in http://www.imagemagick.org/Usage/formats/#jpg_write.
What I was hoping it would do is basically this:
Figure out what sampling-factor, quantization table, and whatever else can be extracted from the input jpg, and use it to compress the output JPEG.
This way, in HDRI and using -dct float, the output should resemble the input reasonably well if no resize occurs.

User avatar
magick
Site Admin
Posts: 11062
Joined: 2003-05-31T11:32:55-07:00

Re: disappointed by -define jpeg:preserve-settings results

Post by magick » 2013-05-12T11:39:21-07:00

The documentation is out-of-date. We preserve sampling factor and image quality but not the quantization tables.

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: disappointed by -define jpeg:preserve-settings results

Post by NicolasRobidoux » 2013-05-12T13:35:54-07:00

Ah! Thank you Cristy.

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: disappointed by -define jpeg:preserve-settings results

Post by anthony » 2013-05-12T19:26:17-07:00

magick wrote:The documentation is out-of-date. We preserve sampling factor and image quality but not the quantization tables.
Updated.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

User avatar
whugemann
Posts: 288
Joined: 2011-03-28T07:11:31-07:00
Authentication code: 8675308
Location: Münster, Germany 52°N,7.6°E

Re: disappointed by -define jpeg:preserve-settings results

Post by whugemann » 2019-03-25T03:25:55-07:00

magick wrote:
2013-05-12T11:39:21-07:00
The documentation is out-of-date. We preserve sampling factor and image quality but not the quantization tables.
The Usage page https://www.imagemagick.org/Usage/formats/#jpg_write still hasn't got it quite right IMHO, as it skips the point that these settings are kept automatically.

However: Why isn't there an option to keep the quantization tables? Wouldn't that be the least intrusive approach?
Wolfgang Hugemann

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: disappointed by -define jpeg:preserve-settings results

Post by anthony » 2019-03-25T18:13:32-07:00

What would you like the documentation to say? ;-)

It is a little confusing as to what exactly the option does. It sounds like the setting is 'true' by default. Does setting it to 'false' disable the preservation? Or does the option just not do anything at all? :-?

Or should I just mention those settings are preserved, and quantization tables aren't at the top, and remove the define all together!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

User avatar
whugemann
Posts: 288
Joined: 2011-03-28T07:11:31-07:00
Authentication code: 8675308
Location: Münster, Germany 52°N,7.6°E

Re: disappointed by -define jpeg:preserve-settings results

Post by whugemann » 2019-03-26T01:31:15-07:00

I think that only the programmers could really answer that question. My impression is that this option just does nothing at the moment. Perhaps one could re-define it in a way that it really does what it claims, i.e. leaving everything, including the DQTs, untouched.

Checking out the other options, I could confirm, that IM switches off chroma subsampling at qualities of 90% and above – which is a rather unexpected thing to do for my taste. I don't think that this is the default behaviour of the JPEG library, as Gimp and IrfanView, which also use the IJG library, behave differently. And all digital cameras still use chroma subsampling at quality levels of 95% an above.

The only program I know of that automatically switches off chroma subsampling at a certain quality level is Adobe Photoshop, at step 7 (https://www.impulseadventure.com/photo/ ... r-web.html).
Wolfgang Hugemann

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: disappointed by -define jpeg:preserve-settings results

Post by anthony » 2019-03-26T16:49:21-07:00

I have removed (HTML Commented) the define from IM Examples. It will update, during normal distribution.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

Post Reply