IM7 Read Exception for specific size transparent PNG

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
RoundedRectangle
Posts: 6
Joined: 2018-07-13T11:09:23-07:00
Authentication code: 1152

IM7 Read Exception for specific size transparent PNG

Post by RoundedRectangle »

Tested on these 2 setups:
ImageMagick 7.0.7-11 Q16 x64 Ubuntu
ImageMagick 7.0.8-7 Q16 x86_64 Win10

A fully transparent 6750x5732 png file created in Photoshop causes this error:

Code: Select all

identify: Read Exception `test.png' @ error/png.c/MagickPNGErrorHandler/1711.
I used this command to reproduce:

Code: Select all

magick identify -verbose "test.png"
Here is the png:
https://imgur.com/ccjXCZb

pngcheck verifies the image file is valid:

Code: Select all

OK: test.png (6750x5732, 32-bit RGB+alpha, non-interlaced, 99.9%).
If I reduce the image size by 1% in Photoshop, it causes no issues with identify -verbose. Here is the smaller file:
https://imgur.com/9bHzF9J

It doesn't happen with a white background, and it doesn't matter what else is in the image, so long as there's transparency. Also saving the image to another format, reopening and resaving as PNG doesn't fix it.

It's happened with a selection of images at different sizes but hopefully this example lets you zero in on the issue.

Same issue occurs with Imagick and PHP7, and also with PHP's GD functions. So not sure if this is something you want to fix or not, but it had me scratching my head for a while.

Or I've overlooked something incredibly simple and hopefully you can enlighten me.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: IM7 Read Exception for specific size transparent PNG

Post by fmw42 »

I can do identify -verbose just fine on IM 6.9.10.6 and IM 7.0.8.6 Mac OSX Sierra just fine on your original PNG image. It is a fully transparent white image.

IM 7.0.8.7 is not released yet, so may be in a state of flux due to development.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: IM7 Read Exception for specific size transparent PNG

Post by snibgo »

IM v7.0.7-28 on Windows 8.1 has no problems reading it:

Code: Select all

Image: ccjXCZb.png
  Format: PNG (Portable Network Graphics)
  Mime type: image/png
  Class: DirectClass
  Geometry: 6750x5732+0+0
  Units: Undefined
  Colorspace: sRGB
  Type: Bilevel
  Base type: Undefined
  Endianess: Undefined
  Depth: 8/1-bit
  Channel depth:
    Red: 1-bit
    Green: 1-bit
    Blue: 1-bit
    Alpha: 1-bit
  Channel statistics:
    Pixels: 38691000
    Red:
      min: 255  (1)
      max: 255 (1)
      mean: 255 (1)
      standard deviation: -1.#IND (-1.#IND)
      kurtosis: 1.39716e+069
      skewness: 3.55222e+049
      entropy: 0
    Green:
      min: 255  (1)
      max: 255 (1)
      mean: 255 (1)
      standard deviation: -1.#IND (-1.#IND)
      kurtosis: 1.39716e+069
      skewness: 3.55222e+049
      entropy: 0
    Blue:
      min: 255  (1)
      max: 255 (1)
      mean: 255 (1)
      standard deviation: -1.#IND (-1.#IND)
      kurtosis: 1.39716e+069
      skewness: 3.55222e+049
      entropy: 0
    Alpha:
      min: 0  (0)
      max: 0 (0)
      mean: 0 (0)
      standard deviation: 0 (0)
      kurtosis: -3
      skewness: 0
      entropy: 0
  Image statistics:
    Overall:
      min: 0  (0)
      max: 255 (1)
      mean: 191.25 (0.75)
      standard deviation: -1.#IND (-1.#IND)
      kurtosis: -0.666667
      skewness: -1.1547
      entropy: 0
  Alpha: srgba(255,255,255,0)   #FFFFFF00
  Colors: 1
  Histogram:
  38691000: (255,255,255,  0) #FFFFFF00 srgba(255,255,255,0)
  Rendering intent: Perceptual
  Gamma: 0.454545
  Chromaticity:
    red primary: (0.64,0.33)
    green primary: (0.3,0.6)
    blue primary: (0.15,0.06)
    white point: (0.3127,0.329)
  Matte color: grey74
  Background color: white
  Border color: srgb(223,223,223)
  Transparent color: none
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 6750x5732+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: Zip
  Orientation: Undefined
  Properties:
    date:create: 2018-07-15T19:13:37+01:00
    date:modify: 2018-07-15T19:12:41+01:00
    png:IHDR.bit-depth-orig: 8
    png:IHDR.bit_depth: 8
    png:IHDR.color-type-orig: 6
    png:IHDR.color_type: 6 (RGBA)
    png:IHDR.interlace_method: 0 (Not interlaced)
    png:IHDR.width,height: 6750, 5732
    png:sRGB: intent=0 (Perceptual Intent)
    signature: a22a602b63a52d5ff70280d74fb9e0f62ecde94dda4c609fecc42ad6faffed8e
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 164437B
  Number pixels: 38691000
  Pixels per second: 40.5992MB
  User time: 3.484u
  Elapsed time: 0:01.952
  Version: ImageMagick 7.0.7-28 Q16 x64 2018-03-25 http://www.imagemagick.org
What happens if you try to convert it to another file, eg:

Code: Select all

magick ccjXCZb.png x.png
For me, that works fine.
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: IM7 Read Exception for specific size transparent PNG

Post by fmw42 »

Is libpng installed and a current version (mine is 1.6.34)?

You can check from

Code: Select all

magick -version
and

Code: Select all

magick -list format
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: IM7 Read Exception for specific size transparent PNG

Post by GeeMack »

Using the example image and testing with ImageMagick 7.0.8-6 Q16 HDRI from a Windows 10 command line, I get no warnings or errors.
RoundedRectangle
Posts: 6
Joined: 2018-07-13T11:09:23-07:00
Authentication code: 1152

Re: IM7 Read Exception for specific size transparent PNG

Post by RoundedRectangle »

Appreciate the checks - libpng 1.2.50 (!!) was the culprit.

Many thanks
Post Reply