Page 1 of 1

Failed to convert PNG file with error " IDAT: invalid distance too far back"

Posted: 2019-03-21T03:42:43-07:00
by long.to
Hi,
When converting a PNG file to another file, I get an error:
convert.exe: IDAT: invalid distance too far back `C:\sample.png' @ error/png.c/MagickPNGErrorHandler/1714.
convert.exe: no images defined `C:\sample.png' @ error/convert.c/ConvertImageCommand/3300.
My sample argument is:

Code: Select all

convert.exe C:\sample.png C:\output.png
I'm using Windows 10 with lastest version of IM : ImageMagick-7.0.8-34

Here is my sample file: https://drive.google.com/file/d/1HHI43P ... 0TPWU/view

Re: Failed to convert PNG file with error " IDAT: invalid distance too far back"

Posted: 2019-03-21T06:20:23-07:00
by snibgo
I get the same error message from IM.

Gimp can read the file with no complaint, but shows an image that is different to that shown on the web download page.

I suppose sample.png is corrupt.

Re: Failed to convert PNG file with error " IDAT: invalid distance too far back"

Posted: 2019-03-21T08:59:16-07:00
by fmw42
On my Mac OSX with IM 6.9.10.34 Q16, I get an error message also

Code: Select all

convert sample.png test.png
convert: no images defined `test.png' @ error/convert.c/ConvertImageCommand/3258.

Mac PREVIEW opens it fine.

Re: Failed to convert PNG file with error " IDAT: invalid distance too far back"

Posted: 2019-03-23T04:09:27-07:00
by dlemstra
It appears that the zlib library is reporting this error. I looks like this is a corrupt image.

Re: Failed to convert PNG file with error " IDAT: invalid distance too far back"

Posted: 2019-03-27T06:59:15-07:00
by 246246
pngfix (comes with libpng) will fix your png.

Code: Select all

$ pngcheck -v sample.png 
File: sample.png (2739 bytes)
  chunk IHDR at offset 0x0000c, length 13
    409 x 242 image, 8-bit palette, non-interlaced
  chunk PLTE at offset 0x00025, length 768: 256 palette entries
  chunk IDAT at offset 0x00331, length 1902
    zlib: deflated, 512-byte window, default compression
    zlib: inflate error = -3 (data error)
ERRORS DETECTED in sample.png

$ pngfix --out=new.png sample.png 
IDAT TFB default 9 15 1902 99220 sample.png

$ pngcheck -v new.png
File: new.png (2739 bytes)
  chunk IHDR at offset 0x0000c, length 13
    409 x 242 image, 8-bit palette, non-interlaced
  chunk PLTE at offset 0x00025, length 768: 256 palette entries
  chunk IDAT at offset 0x00331, length 1902
    zlib: deflated, 32K window, default compression
  chunk IEND at offset 0x00aab, length 0
No errors detected in new.png (4 chunks, 97.2% compression).

$ convert -verbose new.png out.png
new.png PNG 409x242 409x242+0+0 8-bit sRGB 256c 2739B 0.010u 0:00.000
new.png=>out.png PNG 409x242 409x242+0+0 8-bit sRGB 16c 2442B 0.000u 0:00.000