diff -r 3bed35e79f41 -r 292aaba6d6ec degal/thumbnail.py --- a/degal/thumbnail.py Sun Jun 14 23:57:50 2009 +0300 +++ b/degal/thumbnail.py Mon Jun 15 00:23:55 2009 +0300 @@ -63,15 +63,49 @@ height = thumb_height return width, height + + def resize (self, img) : + """ + Resize the give image as needed. + """ + + return img.resize(self.size, resample=PIL.Image.ANTIALIAS) + + def auto_orient (self, img, orient_info) : + """ + Automatically orient the image using the given orientation info. + """ + + # unpack + mirroring, rotation = orient_info + + if mirroring : + # XXX + pass + + if rotation : + # since these are in steps of 90 degrees, it should keep the right size + # but gah, PIL wants these as counter-clockwise! + img = img.rotate(360 - rotation) + + # ok + return img def update (self) : """ Render new output thumbnail. """ + # start with origional image + img = self.image.img + # create resized copy of main image, using our size - thumb = self.image.img.resize(self.size, resample=PIL.Image.ANTIALIAS) + img = self.resize(img) + + # got orientation info? + if self.image.orientation : + img = self.auto_orient(img, self.image.orientation) # write it out - thumb.save(self.path) + img.save(self.path)