From 6a9a50a8b96734c8329ebae3480bad75ee0d3847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milo=C5=A1=20Komar=C4=8Devi=C4=87?= Date: Mon, 13 Nov 2023 19:34:30 +0100 Subject: [PATCH] RAF: get actual sensor dimensions --- src/rafimage.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/rafimage.cpp b/src/rafimage.cpp index 3ad906a68e..7f3bb0be8a 100644 --- a/src/rafimage.cpp +++ b/src/rafimage.cpp @@ -29,14 +29,20 @@ std::string RafImage::mimeType() const { } uint32_t RafImage::pixelWidth() const { - auto widthIter = exifData_.findKey(Exiv2::ExifKey("Exif.Photo.PixelXDimension")); + if (pixelWidth_ != 0) + return pixelWidth_; + + auto widthIter = exifData_.findKey(Exiv2::ExifKey("Exif.Fujifilm.RawImageFullWidth")); if (widthIter == exifData_.end() || widthIter->count() == 0) return 0; return widthIter->toUint32(); } uint32_t RafImage::pixelHeight() const { - auto heightIter = exifData_.findKey(Exiv2::ExifKey("Exif.Photo.PixelYDimension")); + if (pixelHeight_ != 0) + return pixelHeight_; + + auto heightIter = exifData_.findKey(Exiv2::ExifKey("Exif.Fujifilm.RawImageFullHeight")); if (heightIter == exifData_.end() || heightIter->count() == 0) return 0; return heightIter->toUint32(); @@ -319,6 +325,11 @@ void RafImage::readMetadata() { exifData_["Exif.Image2.JPEGInterchangeFormat"] = getULong(jpg_img_offset, bigEndian); exifData_["Exif.Image2.JPEGInterchangeFormatLength"] = getULong(jpg_img_length, bigEndian); + // Todo: parse the proprietary metadata structure + // at offset 92 for pixelWidth_ & pixelHeight_ + // See https://libopenraw.freedesktop.org/formats/raf/ + // and https://exiftool.org/TagNames/FujiFilm.html#RAF + // parse the tiff byte readBuff[4]; if (io_->seek(100, BasicIo::beg) != 0)