Skip to content

Commit e9043b1

Browse files
committed
fried png support
1 parent 2a705a7 commit e9043b1

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

fixtures/sample128x68-fried.png

3.03 KB
Loading

imgspy.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ def probe(stream):
4545
if chunk.startswith(b'\x89PNG\r\n\x1a\n'):
4646
if chunk[12:16] == b'IHDR':
4747
w, h = struct.unpack(">LL", chunk[16:24])
48+
elif chunk[12:16] == b'CgBI':
49+
# fried png http://www.jongware.com/pngdefry.html
50+
chunk += stream.read(40 - len(chunk))
51+
w, h = struct.unpack('>LL', chunk[32:40])
4852
else:
49-
# todo: fried png's http://www.jongware.com/pngdefry.html
5053
w, h = struct.unpack(">LL", chunk[8:16])
5154
return {'type': 'png', 'width': w, 'height': h}
5255
elif chunk.startswith(b'GIF89a') or chunk.startswith(b'GIF87a'):
@@ -112,7 +115,6 @@ def probe(stream):
112115
w, h = h, w
113116
return {'type': 'tiff', 'width': w, 'height': h, 'orientation': orientation}
114117
elif chunk[:4] == b'RIFF' and chunk[8:15] == b'WEBPVP8':
115-
# todo: scales, orientation & validations
116118
w, h = None, None
117119
type = chunk[15:16]
118120
chunk += stream.read(30 - len(chunk))

0 commit comments

Comments
 (0)