Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

writing to to Exif header using the execute() method #22

Open
snowman907 opened this issue Jun 20, 2018 · 1 comment
Open

writing to to Exif header using the execute() method #22

snowman907 opened this issue Jun 20, 2018 · 1 comment

Comments

@snowman907
Copy link

snowman907 commented Jun 20, 2018

My goal is to write data into the Exif-header of an image.
Looking over a post from 2015 link on how to use Exiftool to write to the Exif header. I gave it a try:

import exiftool
fileno=r'DSC00001.JPG
with exiftool.ExifTool() as et:
    et.execute("EXIF:GPSLongitude=100",fileno)
    et.execute("EXIF:GPSLatitude=100",fileno)

In response, I got the following error:

TypeError: sequence item 0: expected a bytes-like object, str found

Then as specified in the documentation, execute takes byte commands, so I bites, so I tried that too:

with exiftool.ExifTool() as et:
   et.execute(bytes("EXIF:GPSLongitude=100", 'utf-8'),fileno)
   et.execute(bytes("EXIF:GPSLatitude=50",'utf-8'),fileno)

But still got the same error :

TypeError: sequence item 1: expected a bytes-like object, str found

I am not sure what am I doing wrong, and if Exiftool can write to file.
Thanks for the help. This question was also posted on StackOverflow here

@zhudaoruyi
Copy link

zhudaoruyi commented Nov 22, 2018

Hi, you should change like the following

import exiftool

fileno=r'DSC00001.JPG
with exiftool.ExifTool() as et:
    et.execute("-GPSLongitude=100",fileno)
    et.execute("-GPSLatitude=100",fileno)

This works well for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants