diff options
author | Nicolas Werner <nicolas.werner@hotmail.de> | 2021-04-04 00:15:08 +0200 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2021-04-04 00:15:08 +0200 |
commit | 007ee38b042bb6d9e424428b031818ce51f3e242 (patch) | |
tree | 514bae99917e032d190a125c8f479342b61d0da5 | |
parent | Fix qtlabs platform in windows packages (diff) | |
download | nheko-007ee38b042bb6d9e424428b031818ce51f3e242.tar.xz |
Fix exif rotation in unencrypted rooms
-rw-r--r-- | src/MxcImageProvider.cpp | 8 | ||||
-rw-r--r-- | src/Utils.cpp | 7 | ||||
-rw-r--r-- | src/Utils.h | 4 |
3 files changed, 16 insertions, 3 deletions
diff --git a/src/MxcImageProvider.cpp b/src/MxcImageProvider.cpp index a20657c8..ab6540a4 100644 --- a/src/MxcImageProvider.cpp +++ b/src/MxcImageProvider.cpp @@ -69,7 +69,7 @@ MxcImageProvider::download(const QString &id, QDir().mkpath(fileInfo.absolutePath()); if (fileInfo.exists()) { - QImage image(fileInfo.absoluteFilePath()); + QImage image = utils::readImageFromFile(fileInfo.absoluteFilePath()); if (!image.isNull()) { image = image.scaled( requestedSize, Qt::KeepAspectRatio, Qt::SmoothTransformation); @@ -143,7 +143,8 @@ MxcImageProvider::download(const QString &id, return; } } else { - QImage image(fileInfo.absoluteFilePath()); + QImage image = + utils::readImageFromFile(fileInfo.absoluteFilePath()); if (!image.isNull()) { then(id, requestedSize, @@ -190,7 +191,8 @@ MxcImageProvider::download(const QString &id, return; } - QImage image(fileInfo.absoluteFilePath()); + QImage image = + utils::readImageFromFile(fileInfo.absoluteFilePath()); image.setText("original filename", QString::fromStdString(originalFilename)); image.setText("mxc url", "mxc://" + id); diff --git a/src/Utils.cpp b/src/Utils.cpp index bf9a8449..ca2d3adc 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -803,6 +803,13 @@ utils::restoreCombobox(QComboBox *combo, const QString &value) } QImage +utils::readImageFromFile(const QString &filename) +{ + QImageReader reader(filename); + reader.setAutoTransform(true); + return reader.read(); +} +QImage utils::readImage(const QByteArray &data) { QBuffer buf; diff --git a/src/Utils.h b/src/Utils.h index 37c1baba..7a9eb777 100644 --- a/src/Utils.h +++ b/src/Utils.h @@ -312,6 +312,10 @@ restoreCombobox(QComboBox *combo, const QString &value); //! Read image respecting exif orientation QImage +readImageFromFile(const QString &filename); + +//! Read image respecting exif orientation +QImage readImage(const QByteArray &data); bool |