@@ -52,15 +52,15 @@ def test_pillow_xmp_add_remove():
5252 im .save (out_heif , format = "HEIF" , xmp = xmp_data )
5353 assert "xmp" not in im .info or im .info ["xmp" ] is None
5454 im_heif = Image .open (out_heif )
55- assert im_heif .info ["xmp" ]
55+ assert im_heif .info ["xmp" ] == xmp_data
5656 # filling `info["xmp"]` before save.
5757 im .info ["xmp" ] = xmp_data
5858 im .save (out_heif , format = "HEIF" )
5959 im_heif = Image .open (out_heif )
60- assert im_heif .info ["xmp" ]
60+ assert im_heif .info ["xmp" ] == xmp_data
6161 # setting `xmp` to `None` during save.
6262 im_heif .save (out_heif_no_xmp , format = "HEIF" , xmp = None )
63- assert im_heif .info ["xmp" ]
63+ assert im_heif .info ["xmp" ] == xmp_data
6464 im_heif_no_xmp = Image .open (out_heif_no_xmp )
6565 assert "xmp" not in im_heif_no_xmp .info or im_heif_no_xmp .info ["xmp" ] is None
6666 # filling `info["xmp"]` with `None` before save.
@@ -85,16 +85,16 @@ def test_heif_xmp_add_remove():
8585 im_heif .save (out_heif , xmp = xmp_data )
8686 assert "xmp" not in im_heif .info or im_heif .info ["xmp" ] is None
8787 im_heif = pillow_heif .open_heif (out_heif )
88- assert im_heif .info ["xmp" ]
88+ assert im_heif .info ["xmp" ] == xmp_data
8989 # test filling `info["xmp"]` before save.
9090 im_heif = pillow_heif .from_pillow (Image .new ("RGB" , (15 , 15 ), 0 ))
9191 im_heif .info ["xmp" ] = xmp_data
9292 im_heif .save (out_heif )
9393 im_heif = pillow_heif .open_heif (out_heif )
94- assert im_heif .info ["xmp" ]
94+ assert im_heif .info ["xmp" ] == xmp_data
9595 # setting `xmp` to `None` during save.
9696 im_heif .save (out_heif_no_xmp , xmp = None )
97- assert im_heif .info ["xmp" ]
97+ assert im_heif .info ["xmp" ] == xmp_data
9898 im_heif_no_xmp = pillow_heif .open_heif (out_heif_no_xmp )
9999 assert "xmp" not in im_heif_no_xmp .info or im_heif_no_xmp .info ["xmp" ] is None
100100 # filling `info["xmp"]` with `None` before save.
@@ -107,3 +107,13 @@ def test_heif_xmp_add_remove():
107107 im_heif .save (out_heif_no_xmp )
108108 im_heif_no_xmp = pillow_heif .open_heif (out_heif_no_xmp )
109109 assert "xmp" not in im_heif_no_xmp .info or im_heif_no_xmp .info ["xmp" ] is None
110+
111+
112+ @pytest .mark .skipif (not helpers .hevc_enc (), reason = "Requires HEVC encoder." )
113+ def test_heif_xmp_latin1_with_zero_byte ():
114+ im = Image .open ("images/heif_other/xmp_latin1.heic" )
115+ out_heif = BytesIO ()
116+ im .save (out_heif , format = "HEIF" )
117+ out_im = Image .open (out_heif )
118+ assert im .getxmp () == out_im .getxmp () # noqa
119+ assert out_im .info ["xmp" ][- 1 ] == 0 # check null byte not to get lost
0 commit comments