diff --git a/README.md b/README.md index 04a6ddd..63586e9 100644 --- a/README.md +++ b/README.md @@ -360,7 +360,7 @@ also use the following string options:** - `KIMAGEFORMATS_HEIF_TEST` to change the behaviour of HEIF tests. Set to `"OFF"` (no test at all) or `"READ_ONLY"` (run read tests only). - `KIMAGEFORMATS_HEJ2_TEST` to change the behaviour of HEJ2 tests. Set to -`"OFF"` (no test at all) or `"READ_ONLY"` (run read tests only).. +`"OFF"` (no test at all) or `"READ_ONLY"` (run read tests only). - `KIMAGEFORMATS_AVCI_TEST` to change the behaviour of AVCI tests. Set to `"OFF"` (no test at all). diff --git a/autotests/write/basic/exr.json b/autotests/write/basic/exr.json index 6feee72..01d3652 100644 --- a/autotests/write/basic/exr.json +++ b/autotests/write/basic/exr.json @@ -32,6 +32,38 @@ { "key" : "Model", "value" : "KImageFormats" + }, + { + "key" : "Comment", + "value" : "This is a test image from KImageFormats" + }, + { + "key" : "Owner", + "value" : "KDE project" + }, + { + "key" : "LensSerialNumber", + "value" : "LEN123456789" + }, + { + "key" : "SerialNumber", + "value" : "CAM123456789" + }, + { + "key" : "ISOSpeedRatings", + "value" : "102" + }, + { + "key" : "ExposureTime", + "value" : "0.015" + }, + { + "key" : "FNumber", + "value" : "1.85" + }, + { + "key" : "FocalLength", + "value" : "6.81" } ], "resolution" : { diff --git a/src/imageformats/exr.cpp b/src/imageformats/exr.cpp index fbcb285..9de2459 100644 --- a/src/imageformats/exr.cpp +++ b/src/imageformats/exr.cpp @@ -365,6 +365,20 @@ static void readMetadata(const Imf::Header &header, QImage &image) if (auto serial = header.findTypedAttribute("lensSerialNumber")) { image.setText(QStringLiteral(META_KEY_LENS_SERIALNUMBER), QString::fromStdString(serial->value())); } + + // shot metadata + if (auto isoSpeed = header.findTypedAttribute("isoSpeed")) { + image.setText(QStringLiteral(META_KEY_ISOSPEEDRATINGS), QLocale::c().toString(qRound(isoSpeed->value()))); + } + if (auto expTime = header.findTypedAttribute("expTime")) { + image.setText(QStringLiteral(META_KEY_EXPOSURETIME), QLocale::c().toString(expTime->value())); + } + if (auto aperture = header.findTypedAttribute("aperture")) { + image.setText(QStringLiteral(META_KEY_FNUMBER), QLocale::c().toString(aperture->value())); + } + if (auto focalLen = header.findTypedAttribute("effectiveFocalLength")) { + image.setText(QStringLiteral(META_KEY_FOCALLENGTH), QLocale::c().toString(focalLen->value())); + } } /*! @@ -587,6 +601,34 @@ static void setMetadata(const QImage &image, Imf::Header &header) if (!key.compare(QStringLiteral(META_KEY_LENS_SERIALNUMBER), Qt::CaseInsensitive)) { header.insert("lensSerialNumber", Imf::StringAttribute(text.toStdString())); } + if (!key.compare(QStringLiteral(META_KEY_ISOSPEEDRATINGS), Qt::CaseInsensitive)) { + auto ok = false; + auto value = QLocale::c().toFloat(text, &ok); + if (ok) { + header.insert("isoSpeed", Imf::FloatAttribute(value)); + } + } + if (!key.compare(QStringLiteral(META_KEY_EXPOSURETIME), Qt::CaseInsensitive)) { + auto ok = false; + auto value = QLocale::c().toFloat(text, &ok); + if (ok) { + header.insert("expTime", Imf::FloatAttribute(value)); + } + } + if (!key.compare(QStringLiteral(META_KEY_FNUMBER), Qt::CaseInsensitive)) { + auto ok = false; + auto value = QLocale::c().toFloat(text, &ok); + if (ok) { + header.insert("aperture", Imf::FloatAttribute(value)); + } + } + if (!key.compare(QStringLiteral(META_KEY_FOCALLENGTH), Qt::CaseInsensitive)) { + auto ok = false; + auto value = QLocale::c().toFloat(text, &ok); + if (ok) { + header.insert("effectiveFocalLength", Imf::FloatAttribute(value)); + } + } } if (dateTime.isValid()) { header.insert("capDate", Imf::StringAttribute(dateTime.toString(QStringLiteral("yyyy:MM:dd HH:mm:ss")).toStdString()));