Permalink
Browse files

fixed problem calling thumbnail on malformed screen grab jpegs

  • Loading branch information...
1 parent 73c0c6c commit b60a0fa8738b6f2fdb4a315c77925ec18bf87cd9 @trey0 trey0 committed Aug 28, 2011
Showing with 5 additions and 1 deletion.
  1. +5 −1 geocamLens/models.py
View
@@ -179,7 +179,11 @@ def makeThumbnail0(self, previewOriginalPath, thumbSize):
im = PIL.Image.open(previewOriginalPath)
fullWidth, fullHeight = im.size
thumbWidth, thumbHeight = self.calcThumbSize(fullWidth, fullHeight, maxOutWidth, maxOutHeight)
- im.thumbnail((thumbWidth, thumbHeight), PIL.Image.ANTIALIAS)
+ try:
+ im.thumbnail((thumbWidth, thumbHeight), PIL.Image.ANTIALIAS)
+ except IOError, e:
+ print >>sys.stderr, 'warning: PIL thumbnail() failed on %s, falling back to resize()' % previewOriginalPath
+ im.resize((thumbWidth, thumbHeight), PIL.Image.ANTIALIAS)
mkdirP(self.getDir())
im.save(self.getThumbnailPath(maxOutWidth))

0 comments on commit b60a0fa

Please sign in to comment.