Skip to content

Commit

Permalink
Fix problems saving Exif data to Xmp sidecar
Browse files Browse the repository at this point in the history
  • Loading branch information
jim-easterbrook committed Dec 6, 2022
1 parent f33ce98 commit 6b45bfc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/photini/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Full documentation is at https://photini.readthedocs.io/"""

__version__ = '2022.12.0.1'
build = '2338 (c736fe3)'
__version__ = '2022.12.0.2'
build = '2339 (f33ce98)'
18 changes: 13 additions & 5 deletions src/photini/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ def to_exif(self):
return str(self)

def to_iptc(self):
return self.to_exif()
return str(self)

def to_xmp(self):
return self.to_exif()
return str(self)

def merge(self, info, tag, other):
result, merged, ignored = self.merge_item(self, other)
Expand Down Expand Up @@ -618,6 +618,10 @@ def from_exiv2(cls, file_value, tag):
file_value = [(short_focal, focal_units), (long_focal, focal_units)]
return cls(file_value)

def to_xmp(self):
return ' '.join(['{}/{}'.format(x.numerator, x.denominator)
for x in self.to_exif()])

def __str__(self):
return ','.join(['{:g}'.format(float(self[x])) for x in self._keys])

Expand Down Expand Up @@ -1166,9 +1170,6 @@ def from_exiv2(cls, file_value, tag):
def to_exif(self):
return str(int(self + 1.5) - 1)

def to_xmp(self):
return str(self)


class MD_Rational(MD_Value, Fraction):
def __new__(cls, value):
Expand All @@ -1177,6 +1178,9 @@ def __new__(cls, value):
def to_exif(self):
return self

def to_xmp(self):
return '{}/{}'.format(self.numerator, self.denominator)

def __str__(self):
return str(float(self))

Expand Down Expand Up @@ -1235,5 +1239,9 @@ def to_exif(self):
file_value.append(apex)
return file_value

def to_xmp(self):
return ['{}/{}'.format(x.numerator, x.denominator)
for x in self.to_exif()]

def contains(self, this, other):
return float(min(other, this)) > (float(max(other, this)) * 0.95)

0 comments on commit 6b45bfc

Please sign in to comment.