sylikc / pyexiftool

PyExifTool (active PyPI project) - A Python library to communicate with an instance of Phil Harvey's ExifTool command-line application. Runs one process with special -stay_open flag, and pipes data to/from. Much more efficient than running a subprocess for each command!
Other
148 stars 19 forks source link

Support for config files #7

Closed asielen closed 3 years ago

asielen commented 3 years ago

To allow for config files (https://exiftool.org/config.html) I made an update to the start method. Config files allow for the creation and setting of custom metadata fields. The limitation though is that if using a config file, it has to be the first argument.

Additionally added an optional parameter to get_metadata which can be used for exporting different formats. eg using the -struct tag to see the hierarchy of the metadata rather than the simplified version.

sylikc commented 3 years ago

interesting. Didn't know about config files.

@asielen Can you point me to a custom config file and a file to test on? I'd probably want to add it into tests

I like the config file idea, though I might add it as an attribute and not in the constructor.

housewarmer commented 3 years ago

Here's the official example custom config: https://exiftool.org/config.html

I second putting it in the constructor – it's a critical component if you're working with custom namespaces/tags.

asielen commented 3 years ago

I initially tried it as an attribute, the challenge is that it always has to be the first argument after the executable. it seemed cleaner to put it in the constructor also because using the config file is global.

sylikc commented 3 years ago

I reviewed the code, and I really don't think params should be an argument on get_metadata and get_metadata_batch. After all, they're both sent into the execute_json call the same way. It's probably better for the caller to combine and send it once.

Can you remove the params change and I'll merge the config_file change

sylikc commented 3 years ago

ok, well, thanks for your config_file contribution @asielen I'll merge the PR as is. Just know that the params= may or may not make it to the 0.5 build (currently being actively developed on the branch https://github.com/sylikc/pyexiftool/tree/v0.5.x-py3-refactor )