diff --git a/sigal/image.py b/sigal/image.py index 555d464..4d36592 100644 --- a/sigal/image.py +++ b/sigal/image.py @@ -52,14 +52,16 @@ class Image(object): self.img = PILImage.open(fp) self.img.load() - exif = self.img._getexif() - if exif: - # see: http://www.impulseadventure.com/photo/exif-orientation.html - orientation = exif.get(EXIF_ORIENTATION_TAG) - rotate_map = {3: 180, 6: -90, 8: 90} - rotation = rotate_map.get(orientation) - if rotation: - self.img = self.img.rotate(rotation) + if hasattr(self.img, '_getexif'): + exif = self.img._getexif() + + if exif: + # http://www.impulseadventure.com/photo/exif-orientation.html + orientation = exif.get(EXIF_ORIENTATION_TAG) + rotate_map = {3: 180, 6: -90, 8: 90} + rotation = rotate_map.get(orientation) + if rotation: + self.img = self.img.rotate(rotation) def save(self, filename, **kwargs): """Save the image. diff --git a/tests/sample/dir1/test1/archlinux-kiss-1024x640.png b/tests/sample/dir1/test1/archlinux-kiss-1024x640.png new file mode 100644 index 0000000..828f84d Binary files /dev/null and b/tests/sample/dir1/test1/archlinux-kiss-1024x640.png differ diff --git a/tests/sample/dir1/test1/index.md b/tests/sample/dir1/test1/index.md new file mode 100644 index 0000000..7c1de62 --- /dev/null +++ b/tests/sample/dir1/test1/index.md @@ -0,0 +1,2 @@ +Title: An example sub-category +Thumbnail: 11.jpg diff --git a/tests/test_gallery.py b/tests/test_gallery.py index 970f0d2..0ed7c65 100644 --- a/tests/test_gallery.py +++ b/tests/test_gallery.py @@ -20,9 +20,9 @@ REF = { 'img': '', }, 'dir1/test1': { - 'title': 'Test1', + 'title': 'An example sub-category', 'thumbnail': '11.jpg', - 'img': ['11.jpg'], + 'img': ['11.jpg', 'archlinux-kiss-1024x640.png'], }, 'dir1/test2': { 'title': 'Test2',