refactor out postprocessing hack to load_end in PcdImageFile

This commit is contained in:
wiredfool 2017-01-01 12:04:59 +00:00
parent a7ce2b69ca
commit 8dd19e6c33
2 changed files with 8 additions and 6 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,6 +42,7 @@ 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
elif orientation == 3:
@ -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