mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-04-27 20:43:43 +03:00
Cleanup code a bit
This commit is contained in:
parent
a520a435d6
commit
3841c96ec6
|
@ -100,42 +100,39 @@ def APP(self, marker):
|
||||||
# reassemble the profile, rather than assuming that the APP2
|
# reassemble the profile, rather than assuming that the APP2
|
||||||
# markers appear in the correct sequence.
|
# markers appear in the correct sequence.
|
||||||
self.icclist.append(s)
|
self.icclist.append(s)
|
||||||
elif marker == 0xFFED:
|
elif marker == 0xFFED and s[:14] == b"Photoshop 3.0\x00":
|
||||||
if s[:14] == b"Photoshop 3.0\x00":
|
# parse the image resource block
|
||||||
blocks = s[14:]
|
offset = 14
|
||||||
# parse the image resource block
|
photoshop = {}
|
||||||
offset = 0
|
while s[offset : offset + 4] == b"8BIM":
|
||||||
photoshop = {}
|
offset += 4
|
||||||
while blocks[offset : offset + 4] == b"8BIM":
|
# resource code
|
||||||
offset += 4
|
try:
|
||||||
# resource code
|
code = i16(s, offset)
|
||||||
try:
|
except struct.error:
|
||||||
code = i16(blocks, offset)
|
break
|
||||||
except struct.error:
|
offset += 2
|
||||||
break
|
# resource name (usually empty)
|
||||||
offset += 2
|
name_len = i8(s[offset])
|
||||||
# resource name (usually empty)
|
# name = s[offset+1:offset+1+name_len]
|
||||||
name_len = i8(blocks[offset])
|
offset += 1 + name_len
|
||||||
# name = blocks[offset+1:offset+1+name_len]
|
offset += offset & 1 # align
|
||||||
offset = 1 + offset + name_len
|
# resource data block
|
||||||
if offset & 1:
|
size = i32(s, offset)
|
||||||
offset += 1
|
offset += 4
|
||||||
# resource data block
|
data = s[offset : offset + size]
|
||||||
size = i32(blocks, offset)
|
if code == 0x03ED: # ResolutionInfo
|
||||||
offset += 4
|
data = {
|
||||||
data = blocks[offset : offset + size]
|
"XResolution": i32(data[:4]) / 65536,
|
||||||
if code == 0x03ED: # ResolutionInfo
|
"DisplayedUnitsX": i16(data[4:8]),
|
||||||
data = {
|
"YResolution": i32(data[8:12]) / 65536,
|
||||||
"XResolution": i32(data[:4]) / 65536,
|
"DisplayedUnitsY": i16(data[12:]),
|
||||||
"DisplayedUnitsX": i16(data[4:8]),
|
}
|
||||||
"YResolution": i32(data[8:12]) / 65536,
|
photoshop[code] = data
|
||||||
"DisplayedUnitsY": i16(data[12:]),
|
offset += size
|
||||||
}
|
offset += offset & 1 # align
|
||||||
photoshop[code] = data
|
self.info["photoshop"] = photoshop
|
||||||
offset = offset + size
|
|
||||||
if offset & 1:
|
|
||||||
offset += 1
|
|
||||||
self.info["photoshop"] = photoshop
|
|
||||||
elif marker == 0xFFEE and s[:5] == b"Adobe":
|
elif marker == 0xFFEE and s[:5] == b"Adobe":
|
||||||
self.info["adobe"] = i16(s, 5)
|
self.info["adobe"] = i16(s, 5)
|
||||||
# extract Adobe custom properties
|
# extract Adobe custom properties
|
||||||
|
|
Loading…
Reference in New Issue
Block a user