Merge pull request #2329 from wiredfool/pcd_hack_refactor

Refactor out postprocessing hack to load_end in PcdImageFile
This commit is contained in:
wiredfool 2017-01-01 19:07:23 +00:00 committed by GitHub
commit ccccd725af
2 changed files with 9 additions and 7 deletions

View File

@ -243,12 +243,6 @@ class ImageFile(Image.Image):
# still raised if decoder fails to return anything
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()
return Image.Image.load(self)

View File

@ -42,8 +42,9 @@ class PcdImageFile(ImageFile.ImageFile):
raise SyntaxError("not a PCD file")
orientation = i8(s[1538]) & 3
self.tile_post_rotate = None
if orientation == 1:
self.tile_post_rotate = 90 # hack
self.tile_post_rotate = 90
elif orientation == 3:
self.tile_post_rotate = -90
@ -51,6 +52,13 @@ class PcdImageFile(ImageFile.ImageFile):
self.size = 768, 512 # FIXME: not correct for rotated images!
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