Copying and Writing EXIF information from one image to another using pyexiv2

后端 未结 2 1301
长情又很酷
长情又很酷 2021-01-01 06:23

Am trying to copy EXIF information of a Image file to the resized version of the same image using pyexiv2. Searching for a solution i stumbled upon a post in Stack Overflow.

2条回答
  •  孤独总比滥情好
    2021-01-01 06:33

    Instead of metadata['Exif.Image.Copyright'] = copyrightName

    You have to use syntax as

    metadata['Exif.Image.Copyright']  = pyexiv2.ExifTag('Exif.Image.Copyright', copyrightName)
    

    Note: copyrightName value should be string for "Exif.Image.Copyright"

    Full example

    import pyexiv2
    metadata = pyexiv2.ImageMetadata(image_name)
    metadata.read() 
    metadata.modified = True
    metadata.writable = os.access(image_name ,os.W_OK)
    metadata['Exif.Image.Copyright']  = pyexiv2.ExifTag('Exif.Image.Copyright', 'copyright@youtext') 
    metadata.write()
    

    hope this may help you

提交回复
热议问题