jmathai / elodie

An EXIF-based photo assistant, organizer and workflow automation tool.
https://bit.ly/introducing-elodie
Apache License 2.0
1.27k stars 139 forks source link

EXIF title only supports ascii characters when updating #27

Closed jmathai closed 8 years ago

jmathai commented 8 years ago

Marking a test as skipped for this by adding # -*- coding: utf-8 to the top of the file.

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/Users/jmathai/elodie/elodie/tests/media/photo.py", line 168, in test_set_title_non_ascii
    status = photo.set_title('形声字 / 形聲字')
  File "/Users/jmathai/elodie/elodie/media/photo.py", line 165, in set_title
    exif_metadata['Xmp.dc.title'] = title
  File "/usr/local/lib/python2.7/site-packages/pyexiv2/metadata.py", line 271, in __setitem__
    return getattr(self, '_set_%s_tag' % family)(key, tag_or_value)
  File "/usr/local/lib/python2.7/site-packages/pyexiv2/metadata.py", line 244, in _set_xmp_tag
    tag = XmpTag(key, tag_or_value)
  File "/usr/local/lib/python2.7/site-packages/pyexiv2/xmp.py", line 114, in __init__
    self._set_value(value)
  File "/usr/local/lib/python2.7/site-packages/pyexiv2/xmp.py", line 235, in _set_value
    raw_value[k.encode('utf-8')] = v.encode('utf-8')
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 0: ordinal not in range(128)
noonat commented 8 years ago

It looks like it's actually encoding it as utf-8, which is the correct behavior, but I think you need to mark your test string as unicode to get the correct behavior.