Skip to content

Commit

Permalink
When restricting image size, respect rotation metadata (fixes #3704)
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Jan 22, 2023
1 parent ad74bdc commit d302fdf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/core/appinterface.cpp
Expand Up @@ -24,6 +24,7 @@

#include <QDirIterator>
#include <QFileInfo>
#include <QImageReader>
#include <qgsmessagelog.h>

AppInterface *AppInterface::sAppInterface = nullptr;
Expand Down Expand Up @@ -163,7 +164,10 @@ void AppInterface::closeSentry() const

void AppInterface::restrictImageSize( const QString &imagePath, int maximumWidthHeight )
{
QImage img( imagePath );
QImageReader imgReader( imagePath );
// Insure that rotation metadata is respected
imgReader.setAutoTransform( true );
QImage img = imgReader.read();
if ( !img.isNull() && ( img.width() > maximumWidthHeight || img.height() > maximumWidthHeight ) )
{
QImage scaledImage = img.width() > img.height()
Expand Down

1 comment on commit d302fdf

@qfield-fairy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.