-
-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4698 from opengisch/backport-4696-to-release-3_0
[Backport release-3_0] Fix problematic image orientation when maximum image size is enabled
- Loading branch information
Showing
9 changed files
with
120 additions
and
3 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
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
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
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
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
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
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
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
e2f41f8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Ta-daaa, freshly created APKs are available: arm64-android
Other architectures