We faced a PNG file that we couldn’t see it. Apparently it had some errors… after struggling with the given PNG file we understood that the CRC of the IHDR chunk is corrupted:
#!/usr/bin/python
import binascii
png = open('img.png','r')
a = png.read(33)
#print a
r = a[29:33]
for h in xrange(60000):
t = a[12:20]
t += binascii.unhexlify("%08x" % h)
t += a[24:29]
print "calc the hex: ", t.encode('hex')
crc = binascii.crc32(t) & 0xffffffff
if r.encode('hex') == hex(crc)[2:]:
break
print "the right width is: 0x%08x" % h
png.close