With regard to viewtopic.php?f=3&t=32526&p=149012#p149099
Would it be possible to add the compression type and/or compression (quality value) for PNG images to the information presented by identify -verbose?
Add png compression to identify -verbose
Re: Add png compression to identify -verbose
Probably not possible and certainly not easy. The PNG format does not explicitly record the "quality", compression method, or filtering method used in compressing the image.
You can make a guess by looking at the filter bytes;
if they are all zero or some other constant N, you can guess that the filtering method was N,
if they are different you can guess that "adaptive filtering" was used.
If they are different but filter methods 3 and 4 weren't used, you can guess that a "adaptive filtering" was used but a "speedy" selection was used.
Zlib records the compression level but only approximately
(fastest, fast, default, and max), according to RFC-1950:
You cannot rely on the validity of the FLEVEL flag. A compressor can write any of those values there regardless of the compression level actually used.
You can make a guess by looking at the filter bytes;
if they are all zero or some other constant N, you can guess that the filtering method was N,
if they are different you can guess that "adaptive filtering" was used.
If they are different but filter methods 3 and 4 weren't used, you can guess that a "adaptive filtering" was used but a "speedy" selection was used.
Zlib records the compression level but only approximately
(fastest, fast, default, and max), according to RFC-1950:
Code: Select all
FLEVEL (Compression level)
These flags are available for use by specific compression
methods. The "deflate" method (CM = 8) sets these flags as
follows:
0 - compressor used fastest algorithm
1 - compressor used fast algorithm
2 - compressor used default algorithm
3 - compressor used maximum compression, slowest algorithm
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Add png compression to identify -verbose
OK. Thanks, Glenn, for the evaluation and explanation. So it appears that one will need to use other tools to check for differences in the same PNG ZIP or ZLIB compression when these kinds of differences occur.
Re: Add png compression to identify -verbose
Yes, the first tool I usually go to is "pngcheck". If you add enough "v's" it will show you the filter method used for each line
(If you add another "v" or two, you'll get every pixel sample, so three is about right for you).
The next tool is "od -c" or "xxd" or my own "pngcrush -n -v" Finally, "identify -verbose". There are others such as "tweakpng".
Code: Select all
pngcheck -vvv file.png
The next tool is "od -c" or "xxd" or my own "pngcrush -n -v" Finally, "identify -verbose". There are others such as "tweakpng".
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Add png compression to identify -verbose
Identify -verbose does not show that information, now, as far as I can tell.
Re: Add png compression to identify -verbose
Right, it doesn't. As I said, you need to use a large toolbox to get everything. For the particular information you wanted,
"pngcheck -vv file.png" provides it. Note that pngcheck is not libpng-based.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Add png compression to identify -verbose
Since it requires a large toolbox and is not simple to fold over, then I will drop this request. It seems to be more work than I had anticipated.