修复IDAT块大小的问题
parent
10fbbc8d6f
commit
6fa426711b
16
type/PNG.py
16
type/PNG.py
|
@ -174,16 +174,22 @@ class PNG:
|
|||
changed = False
|
||||
b = False
|
||||
idat_append = []
|
||||
idat_length = 65445
|
||||
if len(idats) > 0: # 有时候IDAT块大小不是65445,默认用第一个IDAT块大小来检测之后的块
|
||||
idat_length = idats[0][1]
|
||||
for idat in idats:
|
||||
if not b:
|
||||
# 默认每个IDAT数据块最大为65445,如果出现一个数据块小于65445,说明数据块结束。如果后续又出现了IDAT数据块,则说明可能有异常数据
|
||||
if idat[1] < 65445:
|
||||
if idat[1] < idat_length:
|
||||
b = True
|
||||
else:
|
||||
print('[x] 检测到异常IDAT数据块')
|
||||
idat_data = data[idat[0]: idat[0]+idat[1]]
|
||||
idat_result = binascii.hexlify(zlib.decompress(idat_data)) # 究竟是不是要这样处理有待研究
|
||||
idat_append.append[idat_result]
|
||||
try:
|
||||
idat_result = binascii.hexlify(zlib.decompress(idat_data)) # 究竟是不是要这样处理有待研究
|
||||
except Exception as e:
|
||||
idat_result = idat_data
|
||||
idat_append.append(idat_result)
|
||||
|
||||
return changed, data, idat_append
|
||||
|
||||
|
@ -196,7 +202,9 @@ class PNG:
|
|||
pixels_b = []
|
||||
for y in range(height):
|
||||
for x in range(width):
|
||||
r, g, b = image.getpixel((x, y))
|
||||
# result = image.getpixel((x, y))
|
||||
# print(result)
|
||||
r, g, b, a = image.getpixel((x, y))
|
||||
pixels_r.append(r)
|
||||
pixels_g.append(g)
|
||||
pixels_b.append(b)
|
||||
|
|
Loading…
Reference in New Issue