Skip to content

Add keywords to image metadata #102

@artemryzhov

Description

@artemryzhov

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...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions