mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-10-31 07:57:27 +03:00 
			
		
		
		
	Merge pull request #1619 from wiredfool/1477_exif_jpeg
Restore exif data to the v1 form
This commit is contained in:
		
						commit
						6b74b4a7f6
					
				|  | @ -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 | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -140,6 +140,7 @@ TAGS_V2 = { | |||
|     # 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 @@ TAGS = {347: 'JPEGTables', | |||
|         34377: 'PhotoshopInfo', | ||||
|         34850: 'ExposureProgram', | ||||
|         34852: 'SpectralSensitivity', | ||||
|         34853: 'GPSInfoIFD', | ||||
|         34855: 'ISOSpeedRatings', | ||||
|         34856: 'OECF', | ||||
|         34864: 'SensitivityType', | ||||
|  |  | |||
							
								
								
									
										
											BIN
										
									
								
								Tests/images/exif_gps.jpg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Tests/images/exif_gps.jpg
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 1.1 KiB | 
|  | @ -171,6 +171,23 @@ class TestFileJpeg(PillowTestCase): | |||
|         # 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') | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user