Commits

Alexandre Rossi  committed 0216547

do not crash on bad encoding of EXIF Artist

  • Participants
  • Parent commits 47b8d78

Comments (0)

Files changed (3)

File lazygal/metadata.py

 
     def get_authorship(self):
         try:
-            return self.get_exif_string('Exif.Image.Artist')
+            author = self.get_exif_string('Exif.Image.Artist')
+            return self._fallback_to_encoding(author)
         except KeyError:
             return ''
 

File lazygaltest/sample-author-badencoding.jpg

Added
New image

File lazygaltest/test_metadata.py

         im_md = metadata.ImageInfoTags(self.get_sample_path(sample))
         self.assertEqual(im_md.get_focal_length(), '18.0 mm (35 mm equivalent: 27.0 mm)')
 
+    def test_authorship(self):
+        sample = 'sample-author-badencoding.jpg'
+        im_md = metadata.ImageInfoTags(self.get_sample_path(sample))
+        self.assertEqual(im_md.get_authorship(), u'\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd')
+
 
 if __name__ == '__main__':
     unittest.main()