Commit 5cc1560c authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

show focus and subject distance on detail page

parent c810a0af
Loading
Loading
Loading
Loading
+38 −1
Original line number Diff line number Diff line
@@ -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("""<span class="datetime">%d.%m.%Y %H:%M</span>""")
@@ -83,6 +86,13 @@ class ImageHTML:
    def set_flash(self, flash):
        self.flash = f"""<span class="flash">{flash}</span>"""

    def set_focus_distance(self, lower, upper):
        if upper == "inf":
            upper = ""
        self.focus_distance = (
            f"""<span class="focus-distance">{lower}{upper}</span>"""
        )

    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"""<span class="makemodel">{make} {model}</span>"""

    def set_subject_distance(self, distance):
        if distance < 10000:
            self.subject_distance = (
                f"""<span class="subject-distance">{distance} m</span>"""
            )
        else:
            self.subject_distance = f"""<span class="subject-distance">∞</span>"""

    def to_thumbnail_html(self, index, filename, thumbname, with_detail_page=False):

        if with_detail_page:
@@ -179,6 +197,10 @@ class ImageHTML:
            buf += f"<tr><th>Belichtung</th><td>{self.exposure_mode}</td></tr>\n"
        if self.flash:
            buf += f"<tr><th>Blitz</th><td>{self.flash}</td></tr>\n"
        if self.subject_distance:
            buf += f"<tr><th>Entfernung</th><td>{self.subject_distance}</td></tr>\n"
        if self.focus_distance:
            buf += f"<tr><th>Schärfebereich</th><td>{self.focus_distance}</td></tr>\n"
        buf += "</table></p></div>\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()