You are not logged in.

#1 2014-01-13 22:40:43

deepsoul
Member
From: Earth
Registered: 2012-12-23
Posts: 67
Website

[SOLVED] libpng error: IDAT: invalid distance too far back

I have a number of older PNG images from various sources I cannot view any more.  xv outputs the above error message when I try, and display and gimp output similar error messages.  This seems to be an issue with libpng16.  I can view the images on older Linux systems (libpng12 and libpng15) and on (shudder) windoze, so the files themselves do not seem to be broken.

Has anyone experienced the same problem and possibly found a solution?

Last edited by deepsoul (2014-01-22 21:10:35)


Officer, I had to drive home - I was way too drunk to teleport!

Offline

#2 2014-01-14 22:27:40

deepsoul
Member
From: Earth
Registered: 2012-12-23
Posts: 67
Website

Re: [SOLVED] libpng error: IDAT: invalid distance too far back

OK, so I could have done some more research before  posting.  Further web search revealed that libpng intentionally broke backward compatibility with their own past broken output.  Commandlines with optipng and pngcrush are reported as fixing up the alleged PNG files:

pngcrush -fix -force old.png new.png
optipng -quiet -force -fix foo.png

I only used the optipng command - it is in the community repository, where pngcrush is in AUR, and converts in place.

However, this alone did not really solve my problem.  I have hundreds of PNGs, some downloaded (which I do not want to convert), some converted from downloaded GIFs, some created myself, with various libpng versions over the years.  So I wrote a small program called brokenpng that tries to decode a PNG file with libpng and returns 0 (= true in shell) only if libpng bails out.  You use it as follows to generate a list of broken PNGs:

find . -iname \*.png | while read f ; do /path/to/brokenpng $f &>/dev/null && echo $f ; done > /tmp/badpnglist

After inspecting the list and possibly making backups, you can convert them all using 3 parallel jobs:

cat /tmp/badpnglist | xargs -n 1 -P 3 optipng -quiet -force -fix

Disclaimer: brokenpng was quickly written and will return true on libpng errors other than the above.  If you have spaces in your path names, the shell code will not work.


Officer, I had to drive home - I was way too drunk to teleport!

Offline

#3 2014-01-15 17:39:07

glennrp
Member
Registered: 2014-01-15
Posts: 1

Re: [SOLVED] libpng error: IDAT: invalid distance too far back

The "too far back" error report was introduced in libpng-1.6.0 and removed from libpng-1.6.3.  So, please upgrade to libpng-1.6.3 or later (current version is 1.6.8).

Offline

#4 2014-01-15 22:27:47

deepsoul
Member
From: Earth
Registered: 2012-12-23
Posts: 67
Website

Re: [SOLVED] libpng error: IDAT: invalid distance too far back

The version of libpng I use is 1.6.7:

> ldd `which xv` | grep png                           
	libpng16.so.16 => /usr/lib/libpng16.so.16 (0x00007f51988dc000)
> pacman -Qo /usr/lib/libpng16.so.16
/usr/lib/libpng16.so.16 is owned by libpng 1.6.7-1

This is the latest arch package, though it is flagged out of date.  So apparently the error message is still there in the arch version, which I am glad about, because the solution might otherwise have been quite hard to find.

Are you posting on behalf of the libpng project?  If so, thank you for the good documentation that allowed me to write the brokenpng program quickly.  Plenty of discredits for the self-incompatibility without a large-scale file update method, though.


Officer, I had to drive home - I was way too drunk to teleport!

Offline

Board footer

Powered by FluxBB