Write xmp data? #7543
-
Hi Community I try to keep as much metadata as possible when saving images using pillow. Exif data works like a charm by first using getexif() and then passing the argument exif=exif, but the same does not work for xmp: with Image.open(input_path) as img:
exif = img.getexif()
xmp = img.getxmp()
# do some stuff
img.save(output_path, quality=compression_rate, optimize=True, progressive=True, exif=exif, xmp=xmp) It does not throw an error, it just does not write any xmp tags, although they are successfully retrieved. My guess is that it is not implemented that way, i.e. the xmp parameter is not supported. Is that correct? Is there another way of getting this done using pillow, or is it better to use other packages for this? Thanks a lot for your help! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Pillow doesn't currently support saving XMP, no, with one exception - you can save the XMP data for WebP from a string. from PIL import Image
im = Image.open("Tests/images/flower2.webp")
xmp = im.getxmp()
print(len(str(xmp)))
im.save("out.webp", xmp=im.info["xmp"])
reloaded = Image.open("out.webp")
print(len(str(reloaded.getxmp()))) So what image format are you using? |
Beta Was this translation helpful? Give feedback.
-
Thanks for the update! |
Beta Was this translation helpful? Give feedback.
Pillow doesn't currently support saving XMP, no, with one exception - you can save the XMP data for WebP from a string.
So what image format are you using?