mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2026-06-28 07:59:13 -04:00
EXR: added support for additional metadata
This commit is contained in:
@@ -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).
|
||||
|
||||
|
||||
@@ -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" : {
|
||||
|
||||
@@ -365,6 +365,20 @@ static void readMetadata(const Imf::Header &header, QImage &image)
|
||||
if (auto serial = header.findTypedAttribute<Imf::StringAttribute>("lensSerialNumber")) {
|
||||
image.setText(QStringLiteral(META_KEY_LENS_SERIALNUMBER), QString::fromStdString(serial->value()));
|
||||
}
|
||||
|
||||
// shot metadata
|
||||
if (auto isoSpeed = header.findTypedAttribute<Imf::FloatAttribute>("isoSpeed")) {
|
||||
image.setText(QStringLiteral(META_KEY_ISOSPEEDRATINGS), QLocale::c().toString(qRound(isoSpeed->value())));
|
||||
}
|
||||
if (auto expTime = header.findTypedAttribute<Imf::FloatAttribute>("expTime")) {
|
||||
image.setText(QStringLiteral(META_KEY_EXPOSURETIME), QLocale::c().toString(expTime->value()));
|
||||
}
|
||||
if (auto aperture = header.findTypedAttribute<Imf::FloatAttribute>("aperture")) {
|
||||
image.setText(QStringLiteral(META_KEY_FNUMBER), QLocale::c().toString(aperture->value()));
|
||||
}
|
||||
if (auto focalLen = header.findTypedAttribute<Imf::FloatAttribute>("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()));
|
||||
|
||||
Reference in New Issue
Block a user