Closed andrew-taylor closed 1 year ago
Looks like darktable is creating the file in the format {basename}.jpg.xmp
instead of {basename}.xmp
. I can add support for that soon.
@andrew-taylor I made some updates that you can test out by installing the latest pre-release build:
pip install -U --pre naturtag
Now, if you run
naturtag -t 10277 JPEG_example_flower.jpg
It will find and update the XMP file created by darktable. Currently you can't select a .xmp
file directly, only via an associated image file. That's something I could add if you'd like, though.
Thanks. Now breaks with a different error from libxmp for me (appended). Yes I think being able to write xmp file directly would be useful. Andrew
naturtag -t 10277 JPEG_example_flower.jpg
Traceback (most recent call last):
File "/home/andrewt/.local/bin/naturtag", line 8, in <module>
sys.exit(main())
File "/usr/lib/python3/dist-packages/click/core.py", line 1128, in __call__
return self.main(*args, **kwargs)
File "/usr/lib/python3/dist-packages/click/core.py", line 1053, in main
rv = self.invoke(ctx)
File "/usr/lib/python3/dist-packages/click/core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python3/dist-packages/click/core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "/usr/lib/python3/dist-packages/click/decorators.py", line 26, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/andrewt/.local/lib/python3.10/site-packages/naturtag/cli.py", line 187, in tag
metadata_list = list(tag_images(image_paths, observation, taxon))
File "/home/andrewt/.local/lib/python3.10/site-packages/naturtag/metadata/inat_metadata.py", line 81, in tag_images
return [_tag_image(image_path) for image_path in get_valid_image_paths(image_paths, recursive)]
File "/home/andrewt/.local/lib/python3.10/site-packages/naturtag/metadata/inat_metadata.py", line 81, in <listcomp>
return [_tag_image(image_path) for image_path in get_valid_image_paths(image_paths, recursive)]
File "/home/andrewt/.local/lib/python3.10/site-packages/naturtag/metadata/inat_metadata.py", line 73, in _tag_image
img_metadata.write(
File "/home/andrewt/.local/lib/python3.10/site-packages/naturtag/metadata/image_metadata.py", line 134, in write
img.modify_xmp(fixed_xmp)
File "/home/andrewt/.local/lib/python3.10/site-packages/pyexiv2/core.py", line 101, in modify_xmp
self.img.modify_xmp(self._dumps(data), encoding)
RuntimeError: XMP Toolkit error 102: Indexing applied to non-array
Failed to encode XMP metadata.
Okay, it must have something to do with the metadata that darktable is writing. Using that example image without any changes works fine for me:
curl -sO https://upload.wikimedia.org/wikipedia/commons/3/3f/JPEG_example_flower.jpg
naturtag -t 10277 JPEG_example_flower.jpg
It should be fixable, though. I've run into this before with other image editors, and usually it's a case where there are conflicting data types shoved into the same metadata field (like writing a plain string where an array is supposed to go). Could you attach your modified image and sidecar that result in that error? If so, I should be able to narrow down which field is the problem.
Also I'm surprised the exiv2 CLI works here, since naturtag is also using exiv2 under the hood.
Okay, I was able to reproduce it locally and get it fixed (or at least a temporary workaround; the root cause seems fairly obscure).
Try updating again:
pip install -U --pre naturtag
And this should now work as expected:
curl -sO https://upload.wikimedia.org/wikipedia/commons/3/3f/JPEG_example_flower.jpg
darktable JPEG_example_flower.jpg
naturtag -t 10277 JPEG_example_flower.jpg
And you can also select only the .xmp
file now, if you want:
naturtag -t 10277 JPEG_example_flower.jpg.xmp
Apologies for slow reply I've been travelling Confirming working for me (thanks!)
Not sure if this a bug or a feature request - but writing tags to a darktable xmp files fails for me