From be933995f37d90c297e832b5d1e765c94350da89 Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Mon, 22 Aug 2022 12:44:10 +0200 Subject: [PATCH] Fix unrotated images in chat when picture has been taken with Exif only. --- linphone-app/src/utils/Utils.cpp | 8 +++----- linphone-app/ui/modules/Linphone/Chat/ChatFileMessage.qml | 5 ++++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/linphone-app/src/utils/Utils.cpp b/linphone-app/src/utils/Utils.cpp index 43fff1a4b..b1fb49ccb 100644 --- a/linphone-app/src/utils/Utils.cpp +++ b/linphone-app/src/utils/Utils.cpp @@ -112,14 +112,12 @@ QString Utils::toString(const LinphoneEnums::TunnelMode& mode){ QImage Utils::getImage(const QString &pUri) { QImage image(pUri); + QImageReader reader(pUri); + reader.setAutoTransform(true); if(image.isNull()){// Try to determine format from headers instead of using suffix - QImageReader reader(pUri); reader.setDecideFormatFromContent(true); - QByteArray format = reader.format(); - if(!format.isEmpty()) - image = QImage(pUri, format); } - return image; + return reader.read(); } QString Utils::getSafeFilePath (const QString &filePath, bool *soFarSoGood) { if (soFarSoGood) diff --git a/linphone-app/ui/modules/Linphone/Chat/ChatFileMessage.qml b/linphone-app/ui/modules/Linphone/Chat/ChatFileMessage.qml index a0d432b36..a0f082499 100644 --- a/linphone-app/ui/modules/Linphone/Chat/ChatFileMessage.qml +++ b/linphone-app/ui/modules/Linphone/Chat/ChatFileMessage.qml @@ -78,6 +78,7 @@ Row { property real scaleAnimatorTo : ChatStyle.entry.message.file.animation.thumbnailTo mipmap: SettingsModel.mipmapEnabled source: mainRow.contentModel.thumbnail + autoTransform: true fillMode: Image.PreserveAspectFit height: ChatStyle.entry.message.file.height width: height*4/3 @@ -85,7 +86,8 @@ Row { anchors.fill: parent sourceComponent: Image{// Better quality on zoom mipmap: SettingsModel.mipmapEnabled - source:'file:/'+mainRow.contentModel.filePath + source:'image://external/'+mainRow.contentModel.filePath + autoTransform: true fillMode: Image.PreserveAspectFit visible: status == Image.Ready } @@ -102,6 +104,7 @@ Row { property real scaleAnimatorTo : ChatStyle.entry.message.file.animation.to mipmap: SettingsModel.mipmapEnabled source: 'file:/'+mainRow.contentModel.filePath + autoTransform: true fillMode: Image.PreserveAspectFit height: ChatStyle.entry.message.file.heightbetter width: height*4/3