diff --git a/PIL/JpegImagePlugin.py b/PIL/JpegImagePlugin.py index d3c5df0bb..decf04657 100644 --- a/PIL/JpegImagePlugin.py +++ b/PIL/JpegImagePlugin.py @@ -378,7 +378,7 @@ class JpegImageFile(ImageFile.ImageFile): # process dictionary info = TiffImagePlugin.ImageFileDirectory(head) info.load(file) - for key, value in list(info.items()): + for key, value in info.items(): exif[key] = fixup(value) # get exif extension try: @@ -388,7 +388,7 @@ class JpegImageFile(ImageFile.ImageFile): else: info = TiffImagePlugin.ImageFileDirectory(head) info.load(file) - for key, value in list(info.items()): + for key, value in info.items(): exif[key] = fixup(value) # get gpsinfo extension try: @@ -399,7 +399,7 @@ class JpegImageFile(ImageFile.ImageFile): info = TiffImagePlugin.ImageFileDirectory(head) info.load(file) exif[0x8825] = gps = {} - for key, value in list(info.items()): + for key, value in info.items(): gps[key] = fixup(value) return exif diff --git a/PIL/TiffImagePlugin.py b/PIL/TiffImagePlugin.py index 84ce1817a..03d4c94a3 100644 --- a/PIL/TiffImagePlugin.py +++ b/PIL/TiffImagePlugin.py @@ -269,6 +269,11 @@ class ImageFileDirectory(collections.MutableMapping): def __iter__(self): return itertools.chain(self.tags.__iter__(), self.tagdata.__iter__()) + def items(self): + keys = list(self.__iter__()) + values = [self[key] for key in keys] + return zip(keys, values) + # load primitives load_dispatch = {} diff --git a/Tests/test_file_jpeg.py b/Tests/test_file_jpeg.py index 5246930c8..39bff3373 100644 --- a/Tests/test_file_jpeg.py +++ b/Tests/test_file_jpeg.py @@ -177,3 +177,8 @@ def test_truncated_jpeg(): assert_no_exception(lambda: test(4)) assert_no_exception(lambda: test(8)) assert_exception(IOError, lambda: test(10)) + +def test_exif(): + im = Image.open("Tests/images/pil_sample_rgb.jpg") + info = im._getexif() + assert_equal(info[305], 'Adobe Photoshop CS Macintosh')