Repository: python-pillow/Pillow

Issue:
Can't get GPS information in exif - Ver.3.0.0
I executed below scirpt with pillow 2.9.0:

```
from PIL import Image
i = Image.open(r"tests\images\01.jpg")
e = i._getexif()
for key in sorted(e):
    print(str(key) + ": " + str(e[key]))
```

I got below:

```
258: (24, 24, 24)
271: Make
272: XXX-XXX
282: (4294967295, 1)
296: 65535
305: PIL
514: 4294967295
33434: (4294967295, 1)
34665: 185
34853: {0: b'\x00\x00\x00\x01', 2: (4294967295, 1), 5: 1, 30: 65535, 29: '1999:99:99 99:99:99'}
34856: b'\xaa\xaa\xaa\xaa\xaa\xaa'
34867: 4294967295
36867: 2099:09:29 10:10:10
41994: 65535
42034: ((1, 1), (1, 1), (1, 1), (1, 1))
42035: LensMake
```

With 3.0.0, I got below:

```
258: (24, 24, 24)
271: Make
272: XXX-XXX
282: 4294967295.0
296: 65535
305: PIL
514: 4294967295
33434: (4294967295.0,)
34665: 185
34853: (366,)
34856: (b'\xaa\xaa\xaa\xaa\xaa\xaa',)
34867: (4294967295,)
36867: ('2099:09:29 10:10:10',)
37380: (-0.9999999995343387,)
41994: (65535,)
42034: (1.0, 1.0, 1.0, 1.0)
42035: ('LensMake',)
50715: (1.0, 1.0, 1.0)
```

"34853" is a pointer to the GPS information IFD. Ver.2.9.0, it can get GPS informations as dict type.
Ver.3.0.0, it is a int value in tuple(pointer value?).
I looked for about this issue in CHANGES and couldn't find any information.

![01](https://cloud.githubusercontent.com/assets/4497270/10332838/f720c3f6-6d1a-11e5-99f7-25fc31c2133d.jpg) <- JPEG image I used this example.



Discussion:
Looks like a bug, probably similar to https://github.com/python-pillow/Pillow/pull/1465

@hMatoba Please may we include that JPEG in our test suite, under the Pillow MIT-like licence?


Resolving patch:
diff --git a/PIL/JpegImagePlugin.py b/PIL/JpegImagePlugin.py
--- a/PIL/JpegImagePlugin.py
+++ b/PIL/JpegImagePlugin.py
@@ -432,9 +432,9 @@ def _getexif(self):
     except (KeyError, TypeError):
         pass
     else:
-        info = TiffImagePlugin.ImageFileDirectory_v2(head)
+        info = TiffImagePlugin.ImageFileDirectory_v1(head)
         info.load(file)
-        exif[0x8825] = dict(info)
+        exif[0x8825] = dict([(k,v[0]) if len(v) == 1 else (k,v) for k,v in info.items()])
     return exif
 
 
diff --git a/PIL/TiffTags.py b/PIL/TiffTags.py
--- a/PIL/TiffTags.py
+++ b/PIL/TiffTags.py
@@ -140,6 +140,7 @@ def cvt_enum(self, value):
     # FIXME add more tags here
     34665: ("ExifIFD", SHORT, 1),
     34675: ('ICCProfile', 7, 0),
+    34853: ('GPSInfoIFD', 1, 1),
 
     # MPInfo
     45056: ("MPFVersion", 7, 1),
@@ -180,7 +181,6 @@ def cvt_enum(self, value):
         34377: 'PhotoshopInfo',
         34850: 'ExposureProgram',
         34852: 'SpectralSensitivity',
-        34853: 'GPSInfoIFD',
         34855: 'ISOSpeedRatings',
         34856: 'OECF',
         34864: 'SensitivityType',


Test patch:
diff --git a/Tests/images/exif_gps.jpg b/Tests/images/exif_gps.jpg
new file mode 100644
Binary files /dev/null and b/Tests/images/exif_gps.jpg differ
diff --git a/Tests/test_file_jpeg.py b/Tests/test_file_jpeg.py
--- a/Tests/test_file_jpeg.py
+++ b/Tests/test_file_jpeg.py
@@ -171,6 +171,23 @@ def test_exif_typeerror(self):
         # Should not raise a TypeError
         im._getexif()
 
+    def test_exif_gps(self):
+        # Arrange
+        im = Image.open('Tests/images/exif_gps.jpg')
+        gps_index = 34853
+        expected_exif_gps = {
+            0: b'\x00\x00\x00\x01',
+            2: (4294967295, 1),
+            5: b'\x01',
+            30: 65535,
+            29: '1999:99:99 99:99:99'}
+
+        # Act
+        exif = im._getexif()
+
+        # Assert
+        self.assertEqual(exif[gps_index], expected_exif_gps)
+
     def test_exif_gps_typeerror(self):
         im = Image.open('Tests/images/exif_gps_typeerror.jpg')