question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add keywords to image metadata

See original GitHub issue

Hi!

I want to implement feature that add keywords to image metadata, by icloud album title. For example, I have 10 photos in album named “Test album”, and I want to images have keyword “Test album”, for quick search in Shotwell.

The difficulty in implementing data writing to a file…

I tried via piexif:

  exif_dict = piexif.load(path)
  exif_dict.get("0th")[40094] = tags // tags is string 'tag1,tag2'
  exif_bytes = piexif.dump(exif_dict)
  piexif.insert(exif_bytes, path)       

and got error

    zeroth_set = _dict_to_bytes(zeroth_ifd, "0th", 0)
  File "/usr/local/lib/python2.7/dist-packages/piexif/_dump.py", line 337, in _dict_to_bytes
    offset)
  File "/usr/local/lib/python2.7/dist-packages/piexif/_dump.py", line 193, in _value_to_bytes
    value_str = (_pack_byte(*raw_value) +
  File "/usr/local/lib/python2.7/dist-packages/piexif/_dump.py", line 162, in _pack_byte
    return struct.pack("B" * len(args), *args)
struct.error: cannot convert argument to integer

via iptcinfo:

        iptc.keywords = []
        tags = [x.strip() for x in tags.split(',')];
        iptc.keywords.extend(tags)
        iptc.save()

no errors, and no results - tags wasn’t written to file…

Help, please…

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:8

github_iconTop GitHub Comments

2reactions
RhetTbullcommented, Apr 27, 2020

yes, manually tagging the photos with album name would work

0reactions
adamshandcommented, Apr 28, 2020

@RhetTbull that’s amazing! Photos are almost done downloading (will finish overnight) and I was just starting to experiment with tagging my albums by hand. Which was looking pretty tediously slow … so thanks heaps! 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to add, edit and remove keywords in your photo
Open folder with photos in the left panel. · Select photo(-s) that you want to add keywords. · Click button 'Edit EXIF/IPTC' to...
Read more >
Using Image Keywords in your Image Metadata
Whether to include image keywords within image metadata to aid Search Engine Optimisation.
Read more >
Adding keyword metadata to photos - Camera Bits
There are three basic methods for adding keyword metadata to photos in Photo Mechanic. You can type keywords directly into the keywords ......
Read more >
How To Use Image Metadata And Keywords
Use enough keywords to define and locate the picture but don't waste time adding too many keywords. If you do need to add...
Read more >
How to Add Metadata to Images and Video
Open up the folder on your computer that contains the image or video file. · PC users: Right-click on the image, and select...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found