mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-15 17:54:46 +03:00
Codec is always "iptc"
This commit is contained in:
parent
bc2519abf1
commit
68ac3375c6
|
@ -124,35 +124,33 @@ class IptcImageFile(ImageFile.ImageFile):
|
||||||
]
|
]
|
||||||
|
|
||||||
def load(self) -> Image.core.PixelAccess | None:
|
def load(self) -> Image.core.PixelAccess | None:
|
||||||
if len(self.tile) != 1 or self.tile[0][0] != "iptc":
|
if self.tile:
|
||||||
return ImageFile.ImageFile.load(self)
|
offset, compression = self.tile[0][2:]
|
||||||
|
|
||||||
offset, compression = self.tile[0][2:]
|
self.fp.seek(offset)
|
||||||
|
|
||||||
self.fp.seek(offset)
|
# Copy image data to temporary file
|
||||||
|
o = BytesIO()
|
||||||
# Copy image data to temporary file
|
if compression == "raw":
|
||||||
o = BytesIO()
|
# To simplify access to the extracted file,
|
||||||
if compression == "raw":
|
# prepend a PPM header
|
||||||
# To simplify access to the extracted file,
|
o.write(b"P5\n%d %d\n255\n" % self.size)
|
||||||
# prepend a PPM header
|
while True:
|
||||||
o.write(b"P5\n%d %d\n255\n" % self.size)
|
type, size = self.field()
|
||||||
while True:
|
if type != (8, 10):
|
||||||
type, size = self.field()
|
|
||||||
if type != (8, 10):
|
|
||||||
break
|
|
||||||
while size > 0:
|
|
||||||
s = self.fp.read(min(size, 8192))
|
|
||||||
if not s:
|
|
||||||
break
|
break
|
||||||
o.write(s)
|
while size > 0:
|
||||||
size -= len(s)
|
s = self.fp.read(min(size, 8192))
|
||||||
|
if not s:
|
||||||
|
break
|
||||||
|
o.write(s)
|
||||||
|
size -= len(s)
|
||||||
|
|
||||||
with Image.open(o) as _im:
|
with Image.open(o) as _im:
|
||||||
_im.load()
|
_im.load()
|
||||||
self.im = _im.im
|
self.im = _im.im
|
||||||
self.tile = []
|
self.tile = []
|
||||||
return Image.Image.load(self)
|
return ImageFile.ImageFile.load(self)
|
||||||
|
|
||||||
|
|
||||||
Image.register_open(IptcImageFile.format, IptcImageFile)
|
Image.register_open(IptcImageFile.format, IptcImageFile)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user