corrupted image and auto-fixes

Cédric Louvrier said on 10/14/2018

pingo could try to fix some malformed files automatically. if you find a corrupted sample created by a popular image encoder, you could submit it here — however, do not submit if you made a file corrupted on purpose. the malformation must come from the editor/encoder itself

file extension

it is not really file data related but an aside note: on Windows, a tool (or an user) can change the file PNG/JPG extension. the image can be still used in some editors, viewer or even by Web browsers without any notification. however, some tools are not able to process them just because the extension is wrong. since 0.94e, pingo detects if the file is PNG or JPG, and changes the file extension accordingly

PNG auto-fixes

truecolor tRNS

this malformation comes from an invalid tRNS chunk which is way too large. for truecolor images, it should be 6; in this sample, it is 256. pingo removes the corrupted chunk and process the file

corrupted tRNS in truecolor
Truecolor.png — FX-4100 @ 3.6 Ghz - 8 Go RAM - Windows 7 64-bit
tool version option warning output status file
PNGOUT 02/13/2015 - no ok 103.97 KB
PngOptimizer 86146f9 - no check - bad tRNS values (65535) 100.19 KB
TruePNG -md remove all -g0 no ok 98.50 KB
ECT 9c8c626 -9 -s yes * ok no savings
pingo 0.98 -s9 no ok no savings
pingo 0.98.34 -s9 no ok 99.09 KB

* ECT -9 -s: Decoding error 41: tRNS chunk has wrong size for RGB image

number of entries in palette

the number of entries in palette is different from what could be found in image data

  • OptiPNG -fix adds two entries at the end of the palette, making the PNG standard compliant but leaves it unoptimized (256 entries in palette while 249 colors are required)
  • the color 0,0,0 is in image data, but not in palette. PNGOUT 02/13/2015, pingo 0.98.33 or ECT 9c8c626 could corrupt the file: they create this entry, but add a tRNS chunk to make it fully transparent
number of entries in palette
corrupted-palette-num.png — FX-4100 @ 3.6 Ghz - 8 Go RAM - Windows 7 64-bit
tool version option warning output status file
PNGOUT 02/13/2015 - no corrupted 15.04 KB
PngOptimizer 86146f9 - no ok 15.74 KB
ECT 9c8c626 -1 -s yes * ok no savings
ECT 9c8c626 -9 -s no corrupted 14.70 KB
TruePNG -md remove all -g0 yes ** ok no savings
pingo 0.98.33 -s9 no corrupted 14.71 KB
pingo 0.98.34 -s9 no ok 14.69 KB
  • * ECT -1 -s: IDAT: Read palette index exceeding num_palette - Too few colors in PLTE
  • ** truepng -md remove all -g0: There is no such palette entry.

Cédric Louvrier said on 02/27/2019

pingo 0.99 (beta 7) should be able to handle some JPG more efficiently. it should ignore badly corrupted files — but could try to read some. note this is incomplete implementation atm, it works as intended in lossless (low) profiles. an example which should not be rendered, optimized or modified by most of implementation using libjpeg


comment this