Image orientation with qml Camera
-
I'm using Qml Camera to capture an image and send it to the server. The code look something like this
Camera {
id: cameraimageCapture { onImageSaved: { // upload the image. context is the c++ class handling the logic context.uploadImage(path) } } }
the context class use the path to read the content of the file
QFile file(path);
QByteArray fileContent(file.readAll());and the fileContent is attached to a http request and sent to the server.
the problem is, with iOS, when the screen is locked to portrait mode, and i take a photo, the image specified in path did NOT auto rotate. (for example, when i take a photo in horizontal direction, the image should auto rotate 90)
is there anyway to make the image auto rotate before it is sent to the server?
-
Does it also happen when loading the image with
QImageReader
? -
@vudangkhoa2906 said in Image orientation with qml Camera:
it works fine now
Is your issue solved? If so please don't forget to mark your post as such.
-
@Pablo-J-Rogina @GrecKo
I'm really sorry, after a more thorough test, turns out it did not work as i expected. However, I have found a way to rotate the image with code, the only problem is to detect the screen orientation.
Do you guys have any idea how to use it?
As specified in here (https://doc.qt.io/qt-5/qml-qtquick-window-screen.html#orientationUpdateMask-attached-prop), in the main.qml file, I have add this lineApplicationWindow { ... Screen.orientationUpdateMask: Qt.PortraitOrientation | Qt.LandscapeOrientation | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation ... }
however, the Screen.onOrientationChanged signal is not emitted?
fyi: my iPhone is currently in locked portrait mode. but if i disable screen lock, the signal is emitted. -
@vudangkhoa2906 said in Image orientation with qml Camera:
Screen.orientationUpdateMask
I never specified an orientation update mask, and this
readonly property bool isPortrait: (Screen.primaryOrientation === Qt.PortraitOrientation || Screen.primaryOrientation === Qt.InvertedPortraitOrientation)
works fine for me, maybe you don't need it ? 🤷♂️