mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-27 09:44:31 +03:00
Merge pull request #2329 from wiredfool/pcd_hack_refactor
Refactor out postprocessing hack to load_end in PcdImageFile
This commit is contained in:
commit
ccccd725af
|
@ -243,12 +243,6 @@ class ImageFile(Image.Image):
|
||||||
# still raised if decoder fails to return anything
|
# still raised if decoder fails to return anything
|
||||||
raise_ioerror(err_code)
|
raise_ioerror(err_code)
|
||||||
|
|
||||||
# post processing
|
|
||||||
if hasattr(self, "tile_post_rotate"):
|
|
||||||
# FIXME: This is a hack to handle rotated PCD's
|
|
||||||
self.im = self.im.rotate(self.tile_post_rotate)
|
|
||||||
self.size = self.im.size
|
|
||||||
|
|
||||||
self.load_end()
|
self.load_end()
|
||||||
|
|
||||||
return Image.Image.load(self)
|
return Image.Image.load(self)
|
||||||
|
|
|
@ -42,8 +42,9 @@ class PcdImageFile(ImageFile.ImageFile):
|
||||||
raise SyntaxError("not a PCD file")
|
raise SyntaxError("not a PCD file")
|
||||||
|
|
||||||
orientation = i8(s[1538]) & 3
|
orientation = i8(s[1538]) & 3
|
||||||
|
self.tile_post_rotate = None
|
||||||
if orientation == 1:
|
if orientation == 1:
|
||||||
self.tile_post_rotate = 90 # hack
|
self.tile_post_rotate = 90
|
||||||
elif orientation == 3:
|
elif orientation == 3:
|
||||||
self.tile_post_rotate = -90
|
self.tile_post_rotate = -90
|
||||||
|
|
||||||
|
@ -51,6 +52,13 @@ class PcdImageFile(ImageFile.ImageFile):
|
||||||
self.size = 768, 512 # FIXME: not correct for rotated images!
|
self.size = 768, 512 # FIXME: not correct for rotated images!
|
||||||
self.tile = [("pcd", (0, 0)+self.size, 96*2048, None)]
|
self.tile = [("pcd", (0, 0)+self.size, 96*2048, None)]
|
||||||
|
|
||||||
|
def load_end(self):
|
||||||
|
if self.tile_post_rotate:
|
||||||
|
# Handle rotated PCDs
|
||||||
|
self.im = self.im.rotate(self.tile_post_rotate)
|
||||||
|
self.size = self.im.size
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# registry
|
# registry
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user