@@ -219,7 +219,7 @@ def test_exif_gps(self):
219219 gps_index = 34853
220220 expected_exif_gps = {
221221 0 : b"\x00 \x00 \x00 \x01 " ,
222- 2 : ( 4294967295 , 1 ) ,
222+ 2 : 4294967295 ,
223223 5 : b"\x01 " ,
224224 30 : 65535 ,
225225 29 : "1999:99:99 99:99:99" ,
@@ -241,7 +241,7 @@ def test_exif_rollback(self):
241241 36867 : "2099:09:29 10:10:10" ,
242242 34853 : {
243243 0 : b"\x00 \x00 \x00 \x01 " ,
244- 2 : ( 4294967295 , 1 ) ,
244+ 2 : 4294967295 ,
245245 5 : b"\x01 " ,
246246 30 : 65535 ,
247247 29 : "1999:99:99 99:99:99" ,
@@ -253,11 +253,11 @@ def test_exif_rollback(self):
253253 271 : "Make" ,
254254 272 : "XXX-XXX" ,
255255 305 : "PIL" ,
256- 42034 : (( 1 , 1 ), ( 1 , 1 ), ( 1 , 1 ), ( 1 , 1 ) ),
256+ 42034 : (1 , 1 , 1 , 1 ),
257257 42035 : "LensMake" ,
258258 34856 : b"\xaa \xaa \xaa \xaa \xaa \xaa " ,
259- 282 : ( 4294967295 , 1 ) ,
260- 33434 : ( 4294967295 , 1 ) ,
259+ 282 : 4294967295 ,
260+ 33434 : 4294967295 ,
261261 }
262262
263263 with Image .open ("Tests/images/exif_gps.jpg" ) as im :
@@ -647,6 +647,19 @@ def test_invalid_exif(self):
647647 # OSError for unidentified image.
648648 assert im .info .get ("dpi" ) == (72 , 72 )
649649
650+ def test_exif_x_resolution (self , tmp_path ):
651+ with Image .open ("Tests/images/flower.jpg" ) as im :
652+ exif = im .getexif ()
653+ assert exif [282 ] == 180
654+
655+ out = str (tmp_path / "out.jpg" )
656+ with pytest .warns (None ) as record :
657+ im .save (out , exif = exif )
658+ assert len (record ) == 0
659+
660+ with Image .open (out ) as reloaded :
661+ assert reloaded .getexif ()[282 ] == 180
662+
650663 def test_invalid_exif_x_resolution (self ):
651664 # When no x or y resolution is defined in EXIF
652665 with Image .open ("Tests/images/invalid-exif-without-x-resolution.jpg" ) as im :
0 commit comments