const std::string getExiv2ValueString(Exiv2::ExifData& exifData,Exiv2::ExifData::const_iterator it) { if(it!=exifData.end() && it->count()) { return hugin_utils::StrTrim(it->toString()); }; return std::string(""); };
QVariantMap QgsExifTools::readTags( const QString &imagePath ) { std::unique_ptr< Exiv2::Image > image( Exiv2::ImageFactory::open( imagePath.toStdString() ) ); if ( !image ) return QVariantMap(); image->readMetadata(); Exiv2::ExifData &exifData = image->exifData(); if ( exifData.empty() ) { return QVariantMap(); } QVariantMap res; Exiv2::ExifData::const_iterator end = exifData.end(); for ( Exiv2::ExifData::const_iterator i = exifData.begin(); i != end; ++i ) { const QString key = QString::fromStdString( i->key() ); QVariant val; switch ( i->typeId() ) { case Exiv2::asciiString: case Exiv2::string: case Exiv2::comment: case Exiv2::directory: case Exiv2::xmpText: val = QString::fromStdString( i->toString() ); break; case Exiv2::unsignedLong: case Exiv2::signedLong: val = QVariant::fromValue( i->toLong() ); break; case Exiv2::tiffDouble: case Exiv2::tiffFloat: val = QVariant::fromValue( i->toFloat() ); break; case Exiv2::unsignedShort: case Exiv2::signedShort: val = QVariant::fromValue( static_cast< int >( i->toLong() ) ); break; case Exiv2::unsignedRational: case Exiv2::signedRational: case Exiv2::unsignedByte: case Exiv2::signedByte: case Exiv2::undefined: case Exiv2::tiffIfd: case Exiv2::date: case Exiv2::time: case Exiv2::xmpAlt: case Exiv2::xmpBag: case Exiv2::xmpSeq: case Exiv2::langAlt: case Exiv2::invalidTypeId: case Exiv2::lastTypeId: val = QString::fromStdString( i->toString() ); break; } res.insert( key, val ); } return res; }