@@ -317,13 +317,24 @@ def test_save_all() -> None:
317
317
def test_save_xmp () -> None :
318
318
im = Image .new ("RGB" , (1 , 1 ))
319
319
im2 = Image .new ("RGB" , (1 , 1 ), "#f00" )
320
+
321
+ def roundtrip_xmp () -> list [Any ]:
322
+ im_reloaded = roundtrip (im , xmp = b"Default" , save_all = True , append_images = [im2 ])
323
+ xmp = [im_reloaded .info ["xmp" ]]
324
+ im_reloaded .seek (1 )
325
+ return xmp + [im_reloaded .info ["xmp" ]]
326
+
327
+ # Use the save parameters for all frames by default
328
+ assert roundtrip_xmp () == [b"Default" , b"Default" ]
329
+
330
+ # Specify a value for the first frame
331
+ im .encoderinfo = {"xmp" : b"First frame" }
332
+ assert roundtrip_xmp () == [b"First frame" , b"Default" ]
333
+ del im .encoderinfo
334
+
335
+ # Specify value for the second frame
320
336
im2 .encoderinfo = {"xmp" : b"Second frame" }
321
- im_reloaded = roundtrip ( im , xmp = b"First frame " , save_all = True , append_images = [ im2 ])
337
+ assert roundtrip_xmp () == [ b"Default " , b"Second frame" ]
322
338
323
339
# Test that encoderinfo is unchanged
324
340
assert im2 .encoderinfo == {"xmp" : b"Second frame" }
325
-
326
- assert im_reloaded .info ["xmp" ] == b"First frame"
327
-
328
- im_reloaded .seek (1 )
329
- assert im_reloaded .info ["xmp" ] == b"Second frame"
0 commit comments