Skip to content

Commit

Permalink
Round focal lengths, which are potentially expressed as a fraction
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Nov 23, 2024
1 parent 150ab84 commit aa9ed6b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion src/main/php/de/thekid/dialog/processing/Images.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, mixed> {
$r= [];
try {
Expand All @@ -24,7 +30,7 @@ public function meta(File $source): array<string, mixed> {
'apertureFNumber' => $exif->apertureFNumber,
'exposureTime' => $exif->exposureTime,
'isoSpeedRatings' => $exif->isoSpeedRatings,
'focalLength' => $exif->focalLength,
'focalLength' => $this->toRounded($exif->focalLength, precision: 1),
'flashUsed' => $exif->flashUsed(),
];
}
Expand Down

0 comments on commit aa9ed6b

Please sign in to comment.