From aa9ed6b66db6789a758883e5ffd9b98d96ad0fae Mon Sep 17 00:00:00 2001 From: Timm Friebe Date: Sat, 23 Nov 2024 22:13:41 +0400 Subject: [PATCH] Round focal lengths, which are potentially expressed as a fraction --- ChangeLog.md | 3 +++ src/main/php/de/thekid/dialog/processing/Images.php | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index e410c0f..7dc7f1a 100755 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -3,6 +3,9 @@ Dialog change log ## ?.?.? / ????-??-?? +* Changed image import to rounds focal lengths, which are potentially + expressed as a fraction + (@thekid) * Merged PR #62: Extract OpenLayers mapping JS & CSS into separate bundle, reducing the amount of JS to be loaded for the home page by more than 800 kilobytes diff --git a/src/main/php/de/thekid/dialog/processing/Images.php b/src/main/php/de/thekid/dialog/processing/Images.php index 3925939..e1a76c9 100755 --- a/src/main/php/de/thekid/dialog/processing/Images.php +++ b/src/main/php/de/thekid/dialog/processing/Images.php @@ -8,6 +8,12 @@ class Images extends Processing { public function kind(): string { return 'image'; } + /** Rounds focal lengths, which are potentially expressed as a fraction */ + private function toRounded(string $input, int $precision): float { + sscanf($input, '%d/%d', $n, $d); + return null === $d ? (float)$n : round($n / $d, $precision); + } + public function meta(File $source): array { $r= []; try { @@ -24,7 +30,7 @@ public function meta(File $source): array { 'apertureFNumber' => $exif->apertureFNumber, 'exposureTime' => $exif->exposureTime, 'isoSpeedRatings' => $exif->isoSpeedRatings, - 'focalLength' => $exif->focalLength, + 'focalLength' => $this->toRounded($exif->focalLength, precision: 1), 'flashUsed' => $exif->flashUsed(), ]; }