diff options
Diffstat (limited to 'src/pyexiv2.py')
-rw-r--r-- | src/pyexiv2.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/pyexiv2.py b/src/pyexiv2.py index b31bf2c..7a57224 100644 --- a/src/pyexiv2.py +++ b/src/pyexiv2.py @@ -449,6 +449,12 @@ class ExifTag(MetadataTag): except ValueError: raise ExifValueError(value, xtype) + elif xtype in ('Long', 'SLong'): + try: + return long(value) + except ValueError: + raise ExifValueError(value, xtype) + # TODO: other types raise ExifValueError(value, xtype) @@ -469,7 +475,19 @@ class ExifTag(MetadataTag): @raise L{ExifValueError}: if the conversion fails """ if xtype == 'Short': - if type(value) is int: + if type(value) is int and value >= 0: + return str(value) + else: + raise ExifValueError(value, xtype) + + elif xtype == 'Long': + if type(value) in (int, long) and value >= 0: + return str(value) + else: + raise ExifValueError(value, xtype) + + elif xtype == 'SLong': + if type(value) in (int, long): return str(value) else: raise ExifValueError(value, xtype) |