possible bug default jpg quality or doc error
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
possible bug default jpg quality or doc error
IM 6.6.3.1 Q16 Mac OSX Tiger
There is a conflict between the actual default quality achieved (92) in converting to a jpg and the default value of 85 stated at http://www.imagemagick.org/script/comma ... hp#quality as
"For the JPEG and MPEG image formats, quality is 0 (lowest image quality and highest compression) to 100 (best quality but least effective compression). The default is to use the estimate quality of your input image otherwise 85. "
Any non-jpg image I convert to JPG seems to have a quality of 92 listed in the verbose information
For example:
convert logo: logo.jpg
identify -verbose logo.jpg
...
Quality: 92
Is this a bug in converting to JPG, a bug in verbose info, or simply a needed documentation change? Do I misunderstand something?
This issue was originally raised at viewtopic.php?f=1&t=16688
There is a conflict between the actual default quality achieved (92) in converting to a jpg and the default value of 85 stated at http://www.imagemagick.org/script/comma ... hp#quality as
"For the JPEG and MPEG image formats, quality is 0 (lowest image quality and highest compression) to 100 (best quality but least effective compression). The default is to use the estimate quality of your input image otherwise 85. "
Any non-jpg image I convert to JPG seems to have a quality of 92 listed in the verbose information
For example:
convert logo: logo.jpg
identify -verbose logo.jpg
...
Quality: 92
Is this a bug in converting to JPG, a bug in verbose info, or simply a needed documentation change? Do I misunderstand something?
This issue was originally raised at viewtopic.php?f=1&t=16688
Re: possible bug default jpg quality or doc error
The verbose info is alright.fmw42 wrote:Is this [...] a bug in verbose info
Re: possible bug default jpg quality or doc error
We patched the documentation to reflect a default JPEG quality of 92. Thanks.
Re: possible bug default jpg quality or doc error
Can the other things in the quality paragraph be updated, too?
- for JPEG and MPEG, quality is 1 to 100 (or is this a bug? - for PNG, quality 0 doesn't work as expected either)
- the default quality setting for PNG is 75
- with JPEG-2000, the default quality is 100
(After a short test, it seems that a 16:1 compression can be achieved with quality 75 approx. And in the paragraph about the jp2:rate setting, it's specified that quality 75 would result in a rate value of 0.06641, which would be 15:1 - not sure if that's right.)
In the "Common Image Formats" section, there's also a reference to the old JPG quality 85 (search for "is about 85%"):
http://www.imagemagick.org/Usage/formats/#jpg
Thanks!
Again from the "quality" documentation - is this really working?
- for JPEG and MPEG, quality is 1 to 100 (or is this a bug? - for PNG, quality 0 doesn't work as expected either)
- the default quality setting for PNG is 75
- with JPEG-2000, the default quality is 100
(After a short test, it seems that a 16:1 compression can be achieved with quality 75 approx. And in the paragraph about the jp2:rate setting, it's specified that quality 75 would result in a rate value of 0.06641, which would be 15:1 - not sure if that's right.)
In the "Common Image Formats" section, there's also a reference to the old JPG quality 85 (search for "is about 85%"):
http://www.imagemagick.org/Usage/formats/#jpg
Thanks!
Again from the "quality" documentation - is this really working?
When I try to specify a quality like that, I always end up with zlib compression level 9 and JPG quality 100 (from the debug output).When writing a JNG image with transparency, two quality values are required, one for the main image and one for the grayscale image that conveys the alpha channel. These are written as a single integer equal to the main image quality plus 1000 times the opacity quality. For example, if you want to use quality 85 for the main image and quality 90 to compress the opacity data, use -quality 90085.
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
Re: possible bug default jpg quality or doc error
The debugging seems to be hard coded to do that except that I don't get compression level 9, I always get level 8.I always end up with zlib compression level 9 and JPG quality 100 (from the debug output)
In png.c starting at line 8468 I've marked the ones which are hardcoded:
Code: Select all
if (logging != MagickFalse)
{
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" JNG width:%15lu",(unsigned long) image->columns);
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" JNG height:%14lu",(unsigned long) image->rows);
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" JNG color type:%10d",jng_color_type);
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
>> " JNG sample depth:%8d",8);
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
>> " JNG compression:%9d",8);
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
>> " JNG interlace:%11d",0);
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" JNG alpha depth:%9d",jng_alpha_sample_depth);
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" JNG alpha compression:%3d",jng_alpha_compression_method);
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
>> " JNG alpha filter:%8d",0);
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
>> " JNG alpha interlace:%5d",0);
}
In jpeg.c at line 1927:
Code: Select all
#if !defined(C_LOSSLESS_SUPPORTED)
jpeg_set_quality(&jpeg_info,100,MagickTrue);
if (image->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),"Quality: 100");
Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
See my message in this topic for a link to a zip of all the files.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: possible bug default jpg quality or doc error
Default quality for PNG should probably be 95. Remember PNG quality is NOT a value from 0 to 100 but a 0-9 compression and a 0-9 encoding type. 9 compression is the highest compression without loss of data.Drarakel wrote:- the default quality setting for PNG is 75
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: possible bug default jpg quality or doc error
Interesting, when I doAnthony wrote:Default quality for PNG should probably be 95. Remember PNG quality is NOT a value from 0 to 100 but a 0-9 compression and a 0-9 encoding type. 9 compression is the highest compression without loss of data.
convert logo: logo.png
identify -verbose logo.png
There is no quality listed, only the compression!
...
Rendering intent: Undefined
Interlace: None
Background color: white
Border color: rgb(223,223,223)
Matte color: grey74
Transparent color: black
Compose: Over
Page geometry: 640x480+0+0
Dispose: Undefined
Iterations: 0
Compression: Zip
Orientation: Undefined
Properties:
date:create: 2010-08-01T20:34:05-07:00
date:modify: 2010-08-01T20:34:05-07:00
signature: e7339242ec91155fb698eadf06f8e72d8e09f03453d700ed311e446174b75469
Artifacts:
verbose: true
Tainted: False
Filesize: 95KB
Number pixels: 307K
Pixels per second: 6.144M
User time: 0.030u
Elapsed time: 0:01.050
Version: ImageMagick 6.6.3-2 2010-08-01 Q16 http://www.imagemagick.org
So how does one determine the quality value?
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: possible bug default jpg quality or doc error
Like JPEG you probably can not read the quality setting used for the ZIP compressor when the PNG was saved.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: possible bug default jpg quality or doc error
The compression level (the first number in IM) is not a number that you can find out about by looking at the output file, I guess. (But you can list the used setting when creating the file with "-debug coder".)fmw42 wrote:So how does one determine the quality value?
The filter type (the second number) however can be retrieved from the output. pngout for example will display it.
All I'm saying is that the default that ImageMagick currently uses for PNG is 75. And it would be good if these things could be reflected in the documentation.anthony wrote:Default quality for PNG should probably be 95.
We're talking about different things here. You're referring to these settings that start with "JNG...". Maybe "JNG compression" (8) defines the general compression type (Deflate). I don't know..el_supremo wrote:The debugging seems to be hard coded to do that except that I don't get compression level 9, I always get level 8.
But I was talking about the PNG compression level. AFAIK, in JNG the normal image is compressed as JPG and the alpha layer is compressed as PNG (so, lossless). And this compression level from the PNG part is set to 9 when one tries to specify this long 'two quality values' number:
2010-08-02T20:48:47+02:00 0:00.125 0.078u 6.6.3 Coder Magick[1564]: png.c/WriteOnePNGImage/7420/Coder
Compression level: 9
I now think that these long numbers don't work for JNG (at least currently not in the format from the documentation). Everything that's greater than 100 just results in the maximum quality for each part. (One gets the same maximum quality when one specifies a too high quality number with .JPG as output file, for example.) The JPG part gets set to quality 100 (sampling-factor 1x1), and the PNG part gets stored with compression level 9. (It seems that the filter type is 1 then. But I'm not sure about the filter types in JNG, as I don't know if there's a way to extract just the PNG data out of the JNG.. And the debug messages don't show the filter type unless it's filter type 5. And filter type 5 doesn't seem to work in JNG - seems that filter type 0 is used instead of 5..? )
The quality can be specified for JNG - but on my system, it only works with one (normal) quality number. Of course, the PNG part then uses the same 'quality' number as the JPG part.
And when no quality is specified, the default values from the two parts are used. The debug messages show '0' as JPG quality, but the real value is 92 then, and the PNG part uses the PNG default of 75 (but in JNG, 75 seems to be the same as 70).
Re: possible bug default jpg quality or doc error
I noticed that the documentation has been updated. Thanks!
Most of the things are correct now - but not all:
First - there's still this reference to the old JPG default quality here:
http://www.imagemagick.org/Usage/formats/#jpg
http://www.imagemagick.org/script/comma ... hp#quality
Theoretically, a value of '0' or '00' (huffman-only with filter none) should work - but it only results in the default PNG quality (75). It seems that '05' will do a compression with huffman-only and filter none (and for Huffman with adaptive filtering, one has to use e.g. '06' in IM).
And I still think that this paragraph should be overhauled - or deleted (as it doesn't work at the moment):
Most of the things are correct now - but not all:
First - there's still this reference to the old JPG default quality here:
http://www.imagemagick.org/Usage/formats/#jpg
And a few remaining details in the "-quality" documentation:The default quality setting, when no JPEG quality is set, either by the user, or from the source image format file, is about 85%, which is very reasonable.
http://www.imagemagick.org/script/comma ... hp#quality
The second sentence could be deleted or rephrased. There is no '0' or '100' PNG quality value in ImageMagick. '100' will result in PNG quality 90, and '0' will result in 75.For the MNG and PNG image formats, the quality value sets the zlib compression level (quality / 10) and filter-type (quality % 10). Compression levels range from 0 (fastest compression) to 100 (best but slowest).
Theoretically, a value of '0' or '00' (huffman-only with filter none) should work - but it only results in the default PNG quality (75). It seems that '05' will do a compression with huffman-only and filter none (and for Huffman with adaptive filtering, one has to use e.g. '06' in IM).
The first sentence can be deleted.The default is quality is 92, which means nearly the best compression with adaptive filtering. The quality setting has no effect on the appearance of PNG and MNG images, since the compression is always lossless.
And I still think that this paragraph should be overhauled - or deleted (as it doesn't work at the moment):
When writing a JNG image with transparency, two quality values are required, one for the main image and one for the grayscale image that conveys the alpha channel. These are written as a single integer equal to the main image quality plus 1000 times the opacity quality. For example, if you want to use quality 85 for the main image and quality 90 to compress the opacity data, use -quality 90085.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: possible bug default jpg quality or doc error
Many of these things are in Anthony's docs, so you need to get his attention.
Re: possible bug default jpg quality or doc error
Well, you created this thread, didn't you? And it's still about this "-quality" paragraph (with one exception).
This wrong sentence, for example, is a result of the first update in this thread:
http://www.imagemagick.org/script/comma ... hp#quality
This wrong sentence, for example, is a result of the first update in this thread:
http://www.imagemagick.org/script/comma ... hp#quality
If the above two or three remaining things can be corrected, this part of the documentation will be quite perfect.The default is quality is 92, which means nearly the best compression with adaptive filtering.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: possible bug default jpg quality or doc error
I have sent Anthony email to look at your comments again and see about updating his docs. I really don't understand all the issue beyond the default jpg quality that is now 92.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: possible bug default jpg quality or doc error
Fixed. update on offical page shortly.Drarakel wrote:Most of the things are correct now - but not all:
First - there's still this reference to the old JPG default quality here:
http://www.imagemagick.org/Usage/formats/#jpgThe default quality setting, when no JPEG quality is set, either by the user, or from the source image format file, is about 85%, which is very reasonable.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: possible bug default jpg quality or doc error
If you would like to send me a re-write of the command line options page -quality,
http://www.imagemagick.org/script/comma ... hp#quality
I will see it added to the documentation (with appropriate formatting).
It probably should start with something like...
http://www.imagemagick.org/script/comma ... hp#quality
I will see it added to the documentation (with appropriate formatting).
It probably should start with something like...
After that it should split to setting meaning for writing individual image file formats.The -quantity setting is a number defining the internal compression level and style used when writing a image file format. The exact meaning of the setting is dependant on the exact format that is being written.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/