Open auntieyi opened 12 years ago
You are right, we haven't encountered them yet as we use this script for icons only that are created with the safe for web option.
Can you provide the file that had multiple IDAT chunks? I's try to fix it
i also recently stumbled on pngs with multiple idats, and was stumped for a while about why does it only show half of the image until pngcrush told me it has multiple idats and extra compressed data. all existing converter tools only fixed the first chunk.
anyway, here's a sample of iphone optimized png with 2 idat chunks. so far 2 chunks is all i saw. https://dl.dropbox.com/u/62600417/sample_2_idat.png
Dear peperzaken, I've just solved this issue (only half of an image being shown instead of the whole image). This problems is due to the fact that while you must decompress separately each IDAT chunk from the original crushed png, you shall compress them togheter while creating the uncrushed png file (that is you have to concatenate all IDAT uncompressed chunks and then compress them all). After that you can split again each IDAT chunk (whose lenght is arbitrary as per official png specification). By the way, I found uncessary swapping color data (RGBA) and moreover that php gzinflate works well to decompress original IDAT chunks (no external classes required then). I can provide you my source code if you need it. Cheers
Edit: Actually swapping colors can be useful.
I have samples with more than 2 chunks (on the new iPad, PNGs can have up to 8 chunks) if you need them...
Hi CheloXL, The following should work with multiple idat chunks: https://github.com/postypython/pnguncrush It is obviously a rewriting of peperzaken's script.
This PNG does not decode properly using this code, nor does it decode properly with pnguncrush
cannot handle multiple IDAT chunks