-
-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patch QGIS to include exif orientation tag handling fix
- Loading branch information
1 parent
f928e37
commit 5f86cfb
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
diff --git a/src/core/raster/qgsexiftools.cpp b/src/core/raster/qgsexiftools.cpp | ||
index f883d7960c6..51a200d37e5 100644 | ||
--- a/src/core/raster/qgsexiftools.cpp | ||
+++ b/src/core/raster/qgsexiftools.cpp | ||
@@ -472,6 +472,7 @@ bool QgsExifTools::tagImage( const QString &imagePath, const QString &tag, const | ||
return false; | ||
|
||
QVariant actualValue; | ||
+ bool actualValueIsUShort = false; | ||
if ( tag == QLatin1String( "Exif.GPSInfo.GPSLatitude" ) || | ||
tag == QLatin1String( "Exif.GPSInfo.GPSLongitude" ) || | ||
tag == QLatin1String( "Exif.GPSInfo.GPSDestLatitude" ) || | ||
@@ -483,6 +484,11 @@ bool QgsExifTools::tagImage( const QString &imagePath, const QString &tag, const | ||
{ | ||
actualValue = QStringLiteral( "%1/1000" ).arg( static_cast< int>( std::floor( std::abs( value.toDouble() ) * 1000 ) ) ); | ||
} | ||
+ else if ( tag == QLatin1String( "Exif.Image.Orientation" ) ) | ||
+ { | ||
+ actualValueIsUShort = true; | ||
+ actualValue = value; | ||
+ } | ||
else if ( value.type() == QVariant::DateTime ) | ||
{ | ||
const QDateTime dateTime = value.toDateTime(); | ||
@@ -529,8 +535,21 @@ bool QgsExifTools::tagImage( const QString &imagePath, const QString &tag, const | ||
|
||
const bool isXmp = tag.startsWith( QLatin1String( "Xmp." ) ); | ||
image->readMetadata(); | ||
- if ( actualValue.type() == QVariant::Int || | ||
- actualValue.type() == QVariant::LongLong ) | ||
+ if ( actualValueIsUShort ) | ||
+ { | ||
+ if ( isXmp ) | ||
+ { | ||
+ Exiv2::XmpData &xmpData = image->xmpData(); | ||
+ xmpData[tag.toStdString()] = static_cast<ushort>( actualValue.toLongLong() ); | ||
+ } | ||
+ else | ||
+ { | ||
+ Exiv2::ExifData &exifData = image->exifData(); | ||
+ exifData[tag.toStdString()] = static_cast<ushort>( actualValue.toLongLong() ); | ||
+ } | ||
+ } | ||
+ else if ( actualValue.type() == QVariant::Int || | ||
+ actualValue.type() == QVariant::LongLong ) | ||
{ | ||
if ( isXmp ) | ||
{ | ||
@@ -543,8 +562,8 @@ bool QgsExifTools::tagImage( const QString &imagePath, const QString &tag, const | ||
exifData[tag.toStdString()] = static_cast<uint32_t>( actualValue.toLongLong() ); | ||
} | ||
} | ||
- if ( actualValue.type() == QVariant::UInt || | ||
- actualValue.type() == QVariant::ULongLong ) | ||
+ else if ( actualValue.type() == QVariant::UInt || | ||
+ actualValue.type() == QVariant::ULongLong ) | ||
{ | ||
if ( isXmp ) | ||
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters