Skip to content

Commit

Permalink
Use Exiv2::CommentValue to format Exif.Photo.UserComment metadatum
Browse files Browse the repository at this point in the history
Converting the UserComment exif metadatum to string will result in its
direct/quasi-internal string representation of libexiv2, which may
include a "charset=..." prefix with the charset of the value.

Since we want the actual content/value of UserComment, and the
Exiv2::Value held by Exiv2::Exifdatum is Exiv2::CommentValue, then
cast it to call comment(). The result is converted to QString using
QString::fromStdString(), which converts std::string as UTF-8 string.

For further details, see also the exiv2 ticket:
Exiv2/exiv2#1258

Signed-off-by: Pino Toscano <toscano.pino@tiscali.it>
  • Loading branch information
pinotree committed Mar 16, 2024
1 parent 4a5b92e commit 66f4015
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ImageLounge/src/DkCore/DkMetaData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,9 @@ QString DkMetaDataT::getNativeExifValue(const QString &key, bool humanReadable)

// qDebug() << "pos count: " << pos->count();
// Exiv2::Value::AutoPtr v = pos->getValue();
if (humanReadable) {
if (key == QLatin1String("Exif.Photo.UserComment")) {
info = QString::fromStdString(static_cast<const Exiv2::CommentValue &>(pos->value()).comment());
} else if (humanReadable) {
std::stringstream ss;
ss << *pos;
info = exiv2ToQString(ss.str());
Expand Down

0 comments on commit 66f4015

Please sign in to comment.