mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-04 20:03:20 +03:00
Ignore IPTC field that is only zero bytes
This commit is contained in:
parent
fc99a5871e
commit
6bd3ed439a
|
@ -30,6 +30,19 @@ def test_getiptcinfo_jpg_found():
|
||||||
assert iptc[(2, 101)] == b"Hungary"
|
assert iptc[(2, 101)] == b"Hungary"
|
||||||
|
|
||||||
|
|
||||||
|
def test_getiptcinfo_zero_padding():
|
||||||
|
# Arrange
|
||||||
|
with Image.open(TEST_FILE) as im:
|
||||||
|
im.info["photoshop"][0x0404] += b"\x00\x00\x00"
|
||||||
|
|
||||||
|
# Act
|
||||||
|
iptc = IptcImagePlugin.getiptcinfo(im)
|
||||||
|
|
||||||
|
# Assert
|
||||||
|
assert isinstance(iptc, dict)
|
||||||
|
assert len(iptc) == 3
|
||||||
|
|
||||||
|
|
||||||
def test_getiptcinfo_tiff_none():
|
def test_getiptcinfo_tiff_none():
|
||||||
# Arrange
|
# Arrange
|
||||||
with Image.open("Tests/images/hopper.tif") as im:
|
with Image.open("Tests/images/hopper.tif") as im:
|
||||||
|
|
|
@ -58,7 +58,7 @@ class IptcImageFile(ImageFile.ImageFile):
|
||||||
#
|
#
|
||||||
# get a IPTC field header
|
# get a IPTC field header
|
||||||
s = self.fp.read(5)
|
s = self.fp.read(5)
|
||||||
if not len(s):
|
if not s.strip(b"\x00"):
|
||||||
return None, 0
|
return None, 0
|
||||||
|
|
||||||
tag = s[1], s[2]
|
tag = s[1], s[2]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user