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

execute() runs but doesn't write tags #38

Open
martimpassos opened this issue Feb 1, 2022 · 4 comments
Open

execute() runs but doesn't write tags #38

martimpassos opened this issue Feb 1, 2022 · 4 comments

Comments

@martimpassos
Copy link

martimpassos commented Feb 1, 2022

Hello, I'm using the following code to embed metadata to JPEGs:

def embed_metadata(self):
        with ExifTool(executable_=os.environ["EXIFTOOL"]) as et:
            for param in self.__metadata:
                param = param.encode(encoding="utf-8")
                dest = os.path.join(os.environ["JPG"], self.__jpg).encode(
                    encoding="utf-8"
                )
                et.execute(param, dest)

It runs fine, but nothing really happens. No tags get embedded and no jpg_original files are created, as it happened before
with an almost identical function. I have checked the tags content and the destination is built correctly. What am I missing here?

@martimpassos
Copy link
Author

martimpassos commented Feb 1, 2022

I'm running this code on WSL but pointing to the Windows executable. Could this be the issue?

EXIFTOOL=/mnt/c/exiftool.exe

This was the case before too though. I'm just refactoring some code, but locations remain the same.

@sylikc
Copy link

sylikc commented Feb 9, 2022

There might be some problems with your self.__metadata. Also, this isn't the most efficient way to do this... you should embed the metadata all at once one one execute instead of doing like len(self.__metadata) disk writes.

@martimpassos
Copy link
Author

Hi @sylikc thanks for getting back. I'll probably substitute my exiftool.py for your branch's.

However, I have checked the values inside self.__metadata and they're all strings exactly equal to the ones I've been using this far (such as "-GPSLatitudeRef=S"). As for the most efficient way to call execute, can you please confirm this is what I'm looking for? The documentation isn't really clear about how to set tags rather than getting them...

execute(["list","of","params"],dest)

If

This is considered a low-level method, and should rarely be needed by application developers.

, what is the best way to write tags to files?

@sylikc
Copy link

sylikc commented Feb 10, 2022

So... that .execute() comment... you can safely ignore it for setting tags... I think to set tags, that's the best way to do it...

you should be probably doing .execute(*self.__metadata, dest)

That will make exiftool do it all at once, instead of writing to the file like a zillion times. You'll probably have to encode individual parameters though.

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