@@ -317,13 +317,24 @@ def test_save_all() -> None:
317317def test_save_xmp () -> None :
318318 im = Image .new ("RGB" , (1 , 1 ))
319319 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
320336 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" ]
322338
323339 # Test that encoderinfo is unchanged
324340 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