Read image XMP data in Python

后端 未结 6 1816
栀梦
栀梦 2020-12-09 04:20

Can I use PIL, like in this example?

I only need to read the data, and I\'m looking for the easiest simplest way to do it (I can\'t install

6条回答
  •  [愿得一人]
    2020-12-09 04:46

    reading raw file metadata does not work

    This thread started 8 years ago and things might have evolved. I am not very deep in xmp and xml and I think I do not want to be. What I need to do though is to read and write metadata to image files (keywords ratings and the like).

    So python-xmp-toolkit seems to be the best way to do that. It is the python layer based on Exempi as far as I understood.

    So everything goes fine for jpg files. I get a dict with the keys:

    http://ns.adobe.com/xap/1.0/mm/

    http://ns.adobe.com/xap/1.0/

    http://purl.org/dc/elements/1.1/

    http://ns.adobe.com/camera-raw-settings/1.0/

    http://ns.adobe.com/lightroom/1.0/

    http://ns.adobe.com/tiff/1.0/

    http://ns.adobe.com/exif/1.0/

    with those I can access any metadata I wish.

    But when I would like to do the same thing on a raw or sidecar file eg. .raf or .xmp the dict is empty. What am I doing wrong?

    from libxmp.utils import file_to_dict
    xmpPath = '/Users/me/image0001.jpg'
    
    xmpDict = file_to_dict(xmpPath)
    for key in xmpDict.keys():
        print(key)
    

提交回复
热议问题