diff options
| -rw-r--r-- | presentty/image.py | 9 | 
1 files changed, 6 insertions, 3 deletions
| diff --git a/presentty/image.py b/presentty/image.py index d82face..2dbd9ad 100644 --- a/presentty/image.py +++ b/presentty/image.py | |||
| @@ -47,7 +47,11 @@ class ANSIImage(urwid.Widget): | |||
| 47 | def _loadImage(self): | 47 | def _loadImage(self): | 
| 48 | image = PIL.Image.open(self.uri) | 48 | image = PIL.Image.open(self.uri) | 
| 49 | image.load() | 49 | image.load() | 
| 50 | exif = image._getexif() | 50 | try: | 
| 51 | exif = image._getexif() | ||
| 52 | except AttributeError: | ||
| 53 | # No info on whether we should rotate image | ||
| 54 | exif = None | ||
| 51 | if exif: | 55 | if exif: | 
| 52 | orientation = exif.get(274, 1) | 56 | orientation = exif.get(274, 1) | 
| 53 | if orientation == 1: | 57 | if orientation == 1: | 
| @@ -58,8 +62,6 @@ class ANSIImage(urwid.Widget): | |||
| 58 | image = image.rotate(-90) | 62 | image = image.rotate(-90) | 
| 59 | elif orientation == 8: | 63 | elif orientation == 8: | 
| 60 | image = image.rotate(90) | 64 | image = image.rotate(90) | 
| 61 | else: | ||
| 62 | raise Exception("unknown orientation %s" % orientation) | ||
| 63 | return image | 65 | return image | 
| 64 | 66 | ||
| 65 | def pack(self, size, focus=False): | 67 | def pack(self, size, focus=False): | 
| @@ -105,6 +107,7 @@ class ANSIImage(urwid.Widget): | |||
| 105 | stdout=subprocess.PIPE, | 107 | stdout=subprocess.PIPE, | 
| 106 | stderr=subprocess.PIPE) | 108 | stderr=subprocess.PIPE) | 
| 107 | image = self._loadImage() | 109 | image = self._loadImage() | 
| 110 | image = image.convert('RGBA') | ||
| 108 | image.save(jp2a.stdin, 'JPEG') | 111 | image.save(jp2a.stdin, 'JPEG') | 
| 109 | jp2a.stdin.close() | 112 | jp2a.stdin.close() | 
| 110 | data = jp2a.stdout.read() | 113 | data = jp2a.stdout.read() | 
