Closed AviranAbady closed 6 years ago
I've created a demo project showcasing the issue https://github.com/AviranAbady/FotoApparatIssueDemo
the project below has the activity set to portrait only.
The "take photo" button will appear only when the phone is rotated to landscape position (There's an orientation listener)
Once an image is captured, exif is extracted - orientation will be undefined.
@Diolor @dmitry-zaitsev please assist, thanks.
Honestly I don't know how EXIF data behave. Did you find your solution?
@Diolor unfortunately, no.
will photo#rotation
work for you?
@Diolor no, i cant tell from that if the photo is upside down.
on most phones, rotating to the left (90 deg counter clock wise) will result in a normal photo. but on some phones (like nexus 5x) if you rotate to the left (90 deg couter clock wise) you will get an upside down photo.
photo#rotation
would be the same on both phones.
I've created a demo project, linked in the original post, if you wanna have a look.
@Diolor it's not about how to rotate the bitmap, this is about knowing when it needs rotation.
In an app, when the activity is set to portrait only. If a photo is taken when the phone is rotated to landscape... the rotation of the image is unpredictible.
on most phones, if you rotate clock wise it will be upside down. on some phones, it's the other way around...
currently it's impossible to know when you need to rotate it back to normal.
@AviranAbady sorry for the very late reply.
I checked your sample app. The thing is - we pass the JPEG image from the camera as is, and in our configuration the camera is not writing EXIF rotation into the image. So we are writing it manually into the file later on.
What does it mean for you:
PhotoResult.saveToFile
. In that case we write EXIF to the file.Photo
object. To see how it is converted to EXIF rotation check source code of ExifWriter
(it is pretty small).for everyone who reads this discussion, here's the answer:
val orientation = ExifInterface(file.absolutePath).getAttribute(ExifInterface.TAG_ORIENTATION)
I was having this issue as well. After checking checking the code I found that saveToFile write this attribute async, so I just wait it to be done.
photoResult.saveToFile(targetFile)
.whenDone(unit -> {
// do you your stuff here
});
What are you trying to achieve or the steps to reproduce?
Read orientation data from exif
How did you initialize FA?
What was the result you received?
Orientation data in exif is always ORIENTATION_UNDEFINED = 0; checked on several devices
What did you expect?
correct orientation data
Context:
The activity is locked into portrait mode (using manifest) I do rotate the device into landscape mode to take photos Photo.rotationDegrees will have correct values around 90 or 270 when device is in landscape.
FA Version: 1.4.1 Nexus 6p, Nexus 5x