Knowing if an image is portrait or landscape oriented (QmlImage)
-
Hi, ^^
Is there a way to know if an image is portrait or landscape ?
Something like:
Image { source: "some/path/myImage.svg" property bool isPortrait: implicitHeight > implicitWidth // Cause a binding loop, so it's not a solution sourceSize.width: isPortrait ? 0 : 150 // The reason why I want to know the myImage orientation sourceSize.height: isPortrait ? 150 : 0 // The reason why I want to know the myImage orientation }
Thanks a lot ^^
-
@Moisi said in Knowing if an image is portrait or landscape oriented (QmlImage):
There is something I do not understand. Setting the width/height properties makes my images pixellated...
Okay, perhaps like this, it is better:
Image { source: "some/path/myImage.svg" readonly property bool isPortrait: height > width fillMode: Image.PreserveAspectFit sourceSize: Qt.size(150, 150) }
-
Thank you for the answer.
Unfortunately I can't use it for my case because I want to use the orientation to set the sourceSize dimention. So if I do:
Image { source: "some/path/myImage.svg" property bool isPortrait: sourceSize.height> sourceSize.width sourceSize.width: isPortrait ? 0 : 150 // This line is not working sourceSize.height: isPortrait ? 150 : 0 // This line is not working }
My two last lines are not working :/
But maybe it's not the correct way to resize a svg file ?
-
@Moisi said in Knowing if an image is portrait or landscape oriented (QmlImage):
But maybe it's not the correct way to resize a svg file ?
Yes maybe ;)
Image { source: "some/path/myImage.svg" readonly property bool isPortrait: sourceSize.height > sourceSize.width fillMode: Image.PreserveAspectFit width: 150 height: 150 }
-
@Moisi said in Knowing if an image is portrait or landscape oriented (QmlImage):
There is something I do not understand. Setting the width/height properties makes my images pixellated...
Okay, perhaps like this, it is better:
Image { source: "some/path/myImage.svg" readonly property bool isPortrait: height > width fillMode: Image.PreserveAspectFit sourceSize: Qt.size(150, 150) }