-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TIMOB-3887] Android: fix orientation of source image file #8742
Conversation
It appears from my testing that the wrong EXIF orientation value is being detected when the camera is used. For example, with the phone held vertically/portrait the resulting file has an EXIF rotation value of ORIENTATION_ROTATE_90. Based on that, it seems that this bug should be fixed in the base camera classes, not by rotating the imageview. I just happened to publish today a module that works around this bug by both rotating the bitmap and setting the exif orientation tag to portrait. See https://github.com/skypanther/TiRotate Feel free to use code from it. But really, the underlying problem with the captured image is what needs to be fixed here. |
@skypanther Thanks for adding your thoughts here as well! 100 % agree, except that the portrait-in-landscape issue originally is a native Android issue which can be handled in those ways 🚀 |
Clicking through that SO post took me to one that says "ExifInterface doesn't work with all manufactures so use CameraInfo instead" which might explain why my module doesn't work on my Nexus 5x. And, gives me something to look into for resolving that. Thanks! |
2cd4549
to
7f25999
Compare
@fmerzadyan Tested on Samsung S5 and Pixel. The stretching to fit behaviour and rotation looks strange. Can we try something like the Photos/Gallery app. The landscape image will center when device in portrait position, background in black, and fill the view when in device in landscape position? |
@fmerzadyan @jquick-axway |
We should not rotate the bitmap in memory like this. Reason: (Yes, I know a lot of naughty stackoverflow developers do it this way. They're doing it the wrong way.) Better Solution: The JPEG file should not be changed. It's actually normal for JPEGs to have an EXIF orientation setting and all platforms have to deal with it. The difference is that Android forces a developer to rotate a JPEG manually versus other platforms (like Apple) will rotate it upright for you when displayed in UI. Limitation: Note: The above is a refactoring of our image loading code and involves routing most image loading to the TiDrawableReference class if it involves displaying it onscreen. Like camera photos that are too large to be displayed by the GPU. |
Also, what @maggieaxway brought up appears to reveal a separate bug. An ImageView on iOS displays images "letterboxed" versus Android is "stretching" the image. I recommend that we remove the setScaleType(CENTER_IMAGE) change, figure out what the correct behavior should be between all platforms (Android, iOS, Windows Phone), and submit that as a separate PR bug fix. |
Superseded by #9049 Closing. |
Test Case
Set permissions and take picture in four different orientations: up, rotated +- 90 degrees and upside down. Just to check go to your images directory and check that the orientation is the same as at the moment of capture.
JIRA: https://jira.appcelerator.org/browse/TIMOB-3887