Skip to content

Commit

Permalink
Patch QGIS to include exif orientation tag handling fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn authored and github-actions[bot] committed Oct 28, 2023
1 parent f928e37 commit 5f86cfb
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
59 changes: 59 additions & 0 deletions vcpkg/overlay/qgis-qt6/exif_orientation_fix.patch
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 )
{
1 change: 1 addition & 0 deletions vcpkg/overlay/qgis-qt6/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ vcpkg_from_github(
snapping_properties.patch # Remove when updating to QGIS 3.34
exiv2-0.28.patch # Remove when updating to QGIS 3.34
profiler.patch # Remove when updating to QGIS 3.34
exif_orientation_fix.patch # Remove when updating to QGIS 3.34.1
)

file(REMOVE ${SOURCE_PATH}/cmake/FindQtKeychain.cmake)
Expand Down

0 comments on commit 5f86cfb

Please sign in to comment.