Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read lens model and pass it to EXIF data #6

Merged
merged 4 commits into from
Jan 1, 2025
Merged

Conversation

thekid
Copy link
Member

@thekid thekid commented Dec 22, 2024

Example

img.util.ExifData(6000 x 4000 image/jpeg)@{
  [file            ] input stream (-1 bytes)
  [make            ] Canon
  [model           ] Canon EOS 250D
  [lensModel       ] EF8-15mm f/4L FISHEYE USM
  [software        ] Adobe Photoshop Elements 18.0 (Windows)
  [flash           ] 0 (off)
  [orientation     ] 1 (horizontal, normal)
  [dateTime        ] 2024-11-23 10:14:53+0400
  [apertureFNumber ] f/14.0
  [exposureTime    ] 1/100
  [exposureProgram ] 3 (aperture priority)
  [meteringMode    ] 5 (pattern)
  [whitebalance    ] 0
  [isoSpeedRatings ] 100
  [focalLength     ] 10
}

See https://stackoverflow.com/questions/39929814/exif-data-lensmodel-property

@thekid
Copy link
Member Author

thekid commented Dec 22, 2024

iPhone 16 stores this only in the XMP segment, while the older iPhone XS includes it in both places.

use img\io\{MetaDataReader, XMPSegment};
use io\streams\FileInputStream;

$reader= new MetaDataReader();
if ($xmp= $reader->read(new FileInputStream($argv[1]))->segmentsOf(XMPSegment::class)) {
  $rdf= 'http://www.w3.org/1999/02/22-rdf-syntax-ns#';

  // iPhone 16 back dual wide camera 5.96mm f/1.6
  $lens= $xmp[0]->document()
    ->getElementsByTagNameNS($rdf, 'Description')[0]
    ->attributes['LensModel']
    ->value
  ;
}

@thekid thekid merged commit e6569fd into master Jan 1, 2025
12 checks passed
@thekid thekid deleted the feature/lens-model branch January 1, 2025 12:48
@thekid
Copy link
Member Author

thekid commented Jan 1, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant