From 5cc1560c51ce452146a30e295cd5fc4903c8539d Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 3 Jun 2021 23:09:27 +0200 Subject: show focus and subject distance on detail page --- bin/pyggle | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/pyggle b/bin/pyggle index 92b260d..656846f 100755 --- a/bin/pyggle +++ b/bin/pyggle @@ -62,12 +62,15 @@ class ImageHTML: self.make = None self.focus = None - self.f_num = None self.exposure = None self.exposure_mode = None self.exposure_program = None + self.f_num = None + self.flash = None self.focal_length = None + self.focus_distance = None self.iso = None + self.subject_distance = None def set_datetime(self, dt): self.datetime = dt.strftime("""%d.%m.%Y %H:%M""") @@ -83,6 +86,13 @@ class ImageHTML: def set_flash(self, flash): self.flash = f"""{flash}""" + def set_focus_distance(self, lower, upper): + if upper == "inf": + upper = "∞" + self.focus_distance = ( + f"""{lower} – {upper}""" + ) + def set_focus( self, f_num, exposure, focal_length, focal_length35, crop_factor, iso ): @@ -128,6 +138,14 @@ class ImageHTML: def set_makemodel(self, make, model): self.make = f"""{make} {model}""" + def set_subject_distance(self, distance): + if distance < 10000: + self.subject_distance = ( + f"""{distance} m""" + ) + else: + self.subject_distance = f"""""" + def to_thumbnail_html(self, index, filename, thumbname, with_detail_page=False): if with_detail_page: @@ -179,6 +197,10 @@ class ImageHTML: buf += f"Belichtung{self.exposure_mode}\n" if self.flash: buf += f"Blitz{self.flash}\n" + if self.subject_distance: + buf += f"Entfernung{self.subject_distance}\n" + if self.focus_distance: + buf += f"Schärfebereich{self.focus_distance}\n" buf += "

\n" return buf @@ -259,6 +281,21 @@ class Thumbnail: except KeyError: pass + try: + self.html.set_subject_distance( + float(self.exif_tag["EXIF SubjectDistance"].values[0]) + ) + except (KeyError, ZeroDivisionError): + pass + + try: + self.html.set_focus_distance( + self.exiftool["MakerNotes:FocusDistanceLower"], + self.exiftool["MakerNotes:FocusDistanceUpper"], + ) + except KeyError: + pass + def _get_focus(self): entries = list() -- cgit v1.2.3