Identifying palette PNG

Przemysław Sobala <[email protected]> Tue, 2 Jul 2019 10:21:27 +0200
Newsgroups gmane.comp.video.graphicsmagick.help
Message-ID <[email protected]>
Hello

I want to identify image files with color palette by GraphicsMagick C++ 
API but I started with GM CLI:

$ gm identify -verbose palette-world.png
Image: palette-world.png
   Format: PNG (Portable Network Graphics)
   Geometry: 570x398
   Class: DirectClass
*Type: true color with transparency*
   Depth: 8 bits-per-pixel component
   Channel Depths:
     Red:      8 bits
     Green:    8 bits
     Blue:     8 bits
     Opacity:  8 bits
   Channel Statistics:
     Red:
       Minimum:                     0.00 (0.0000)
       Maximum:                   245.00 (0.9608)
       Mean:                       58.44 (0.2292)
       Standard Deviation:         97.75 (0.3833)
     Green:
       Minimum:                     0.00 (0.0000)
       Maximum:                   255.00 (1.0000)
       Mean:                       61.36 (0.2406)
       Standard Deviation:        102.33 (0.4013)
     Blue:
       Minimum:                     0.00 (0.0000)
       Maximum:                   255.00 (1.0000)
       Mean:                       63.47 (0.2489)
       Standard Deviation:        105.62 (0.4142)
     Opacity:
       Minimum:                     0.00 (0.0000)
       Maximum:                   255.00 (1.0000)
       Mean:                      191.23 (0.7499)
       Standard Deviation:        108.45 (0.4253)
   Opacity: (  0,  0,  0,255)      #000000FF
   Filesize: 28.8Ki
   Interlace: No
   Orientation: Unknown
   Background Color: white
   Border Color: #DFDFDF00
   Matte Color: #BDBDBD00
   Page geometry: 570x398+0+0
   Compose: Over
   Dispose: Undefined
   Iterations: 0
   Compression: Zip
*Png:IHDR.color-type-orig: 3*
   Png:IHDR.bit-depth-orig: 8
   Signature: 
7c31b2b0734aea24f798f0ac94b13f96dbe7e1dca3030c2f4e2f8472763ced92
   Tainted: False
   User Time: 0.050u
   Elapsed Time: 0m:0.012858s
   Pixels Per Second: 16.8Mi

The *Type*property is set to *true color* and it turns out that the only 
way to know if input PNG file is a palette one is via reading 
Png:IHDR.color-type-origproperty (value 3 means "Each pixel is a palette 
index").

GIF files, on the other hand, are reported correctly:

Image: earth.gif
  Format: GIF (CompuServe graphics interchange format)
  Geometry: 400x400
  Class: PseudoClass
*Type: palette*

--
regards
Przemysław Sobala

_______________________________________________
Graphicsmagick-help mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/graphicsmagick-help