From bf9a6737bee0c8ddc35d878c20efa35386551733 Mon Sep 17 00:00:00 2001 From: Timm Friebe Date: Sun, 22 Dec 2024 18:04:17 +0100 Subject: [PATCH 1/4] Read lens model and pass it to EXIF data --- src/main/php/img/io/ExifSegment.class.php | 7 ++++--- src/main/php/img/util/ExifData.class.php | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main/php/img/io/ExifSegment.class.php b/src/main/php/img/io/ExifSegment.class.php index 75a29f02..58bbdb4f 100755 --- a/src/main/php/img/io/ExifSegment.class.php +++ b/src/main/php/img/io/ExifSegment.class.php @@ -1,7 +1,7 @@ 'Sharpness', 0xA40B => 'DeviceSettingDescription', 0xA40C => 'SubjectDistanceRange', - 0xA420 => 'ImageUniqueID' + 0xA420 => 'ImageUniqueID', + 0xA434 => 'LensModel', ]; /** @@ -583,7 +584,7 @@ public function rawData($arg= null) { * @return string */ public function toString() { - return nameof($this).'<'.$this->marker.'>'.\xp::stringOf($this->data); + return nameof($this).'<'.$this->marker.'>'.Objects::stringOf($this->data); } /** diff --git a/src/main/php/img/util/ExifData.class.php b/src/main/php/img/util/ExifData.class.php index 1c16b488..7003d53c 100755 --- a/src/main/php/img/util/ExifData.class.php +++ b/src/main/php/img/util/ExifData.class.php @@ -16,6 +16,7 @@ class ExifData implements Value { $width = 0, $make = '', $model = '', + $lensModel = '', $flash = 0, $orientation = 0, $fileName = '', @@ -79,6 +80,17 @@ public function withModel($model) { return $this; } + /** + * Set Lens Model + * + * @param string model + * @return self + */ + public function withLensModel($lensModel) { + $this->lensModel= $lensModel; + return $this; + } + /** * Set Flash * @@ -375,6 +387,7 @@ public function toString() { " [file ] %s (%d bytes)\n". " [make ] %s\n". " [model ] %s\n". + " [lensModel ] %s\n". " [software ] %s\n". " [flash ] %d (%s)\n". " [orientation ] %s (%s, %s)\n". @@ -395,6 +408,7 @@ public function toString() { $this->fileSize, $this->make, $this->model, + $this->lensModel, $this->software, $this->flash, $this->flashUsed() ? 'on' : 'off', From e44eca2c390b5252b6611b90a74488daf43ac6f1 Mon Sep 17 00:00:00 2001 From: Timm Friebe Date: Sun, 22 Dec 2024 18:05:18 +0100 Subject: [PATCH 2/4] Pass lens model to ExifData instance --- src/main/php/img/io/ImageMetaData.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/php/img/io/ImageMetaData.class.php b/src/main/php/img/io/ImageMetaData.class.php index c9af9ee7..3d39ae7c 100755 --- a/src/main/php/img/io/ImageMetaData.class.php +++ b/src/main/php/img/io/ImageMetaData.class.php @@ -161,6 +161,7 @@ public function exifData($tz= null) { $data->withMake(null === ($l= self::lookup($raw, 'Make')) ? null : trim($l)); $data->withModel(null === ($l= self::lookup($raw, 'Model')) ? null : trim($l)); + $data->withLensModel(null === ($l= self::lookup($raw, 'LensModel')) ? null : trim($l)); $data->withSoftware(null === ($l= self::lookup($raw, 'Software')) ? null : trim($l)); $exif= $raw['Exif_IFD_Pointer']['data']; From db057b983c6912d28954683de2bc8ef58a380a58 Mon Sep 17 00:00:00 2001 From: Timm Friebe Date: Sun, 22 Dec 2024 18:38:57 +0100 Subject: [PATCH 3/4] Correctly look up "LensModel" in EXIF --- src/main/php/img/io/ImageMetaData.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/php/img/io/ImageMetaData.class.php b/src/main/php/img/io/ImageMetaData.class.php index 3d39ae7c..7567f779 100755 --- a/src/main/php/img/io/ImageMetaData.class.php +++ b/src/main/php/img/io/ImageMetaData.class.php @@ -161,10 +161,10 @@ public function exifData($tz= null) { $data->withMake(null === ($l= self::lookup($raw, 'Make')) ? null : trim($l)); $data->withModel(null === ($l= self::lookup($raw, 'Model')) ? null : trim($l)); - $data->withLensModel(null === ($l= self::lookup($raw, 'LensModel')) ? null : trim($l)); $data->withSoftware(null === ($l= self::lookup($raw, 'Software')) ? null : trim($l)); $exif= $raw['Exif_IFD_Pointer']['data']; + $data->withLensModel(null === ($l= self::lookup($exif, 'LensModel')) ? null : trim($l)); if ($sof= $this->segmentsOf(SOFNSegment::class)) { $data->withWidth($sof[0]->width()); From e2ed9119e2a8211bdf3d90a557220c41b564bde0 Mon Sep 17 00:00:00 2001 From: Timm Friebe Date: Sun, 22 Dec 2024 18:46:06 +0100 Subject: [PATCH 4/4] Include fix for dates with microseconds --- src/main/php/img/io/ImageMetaData.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/php/img/io/ImageMetaData.class.php b/src/main/php/img/io/ImageMetaData.class.php index 7567f779..3c5e4ece 100755 --- a/src/main/php/img/io/ImageMetaData.class.php +++ b/src/main/php/img/io/ImageMetaData.class.php @@ -213,7 +213,8 @@ public function exifData($tz= null) { $data->withFlash(self::lookup($exif, 'Flash')); if (null !== ($date= self::lookup($exif, 'DateTimeOriginal', 'DateTimeDigitized', 'DateTime'))) { - $data->withDateTime(new Date($date, $tz)); + sscanf($date, '%d:%d:%d %d:%d:%d', $year, $month, $day, $hour, $minute, $second); + $data->withDateTime(Date::create($year, $month, $day, $hour, $minute, $second, $tz)); } if (null !== ($o= self::lookup($exif, 'Orientation'))) {