From 8dd19e6c3391557fddf00efed83dba87c144b229 Mon Sep 17 00:00:00 2001 From: wiredfool Date: Sun, 1 Jan 2017 12:04:59 +0000 Subject: [PATCH] refactor out postprocessing hack to load_end in PcdImageFile --- PIL/ImageFile.py | 6 ------ PIL/PcdImagePlugin.py | 8 ++++++++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/PIL/ImageFile.py b/PIL/ImageFile.py index 52c2ed34c..a56795751 100644 --- a/PIL/ImageFile.py +++ b/PIL/ImageFile.py @@ -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) diff --git a/PIL/PcdImagePlugin.py b/PIL/PcdImagePlugin.py index b53635a99..0cf348e74 100644 --- a/PIL/PcdImagePlugin.py +++ b/PIL/PcdImagePlugin.py @@ -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