[TIMOB-27872] Android: Blob imageAsX() methods ignore EXIF orientation if not wrapping a file
GitHub Issue | n/a |
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2020-08-11T13:13:50.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 9.1.0 |
Components | Android |
Labels | android, blob, exif, jpeg, orientation |
Reporter | Samir Mohammed |
Assignee | Joshua Quick |
Created | 2020-04-29T16:21:18.000+0000 |
Updated | 2020-08-11T13:13:50.000+0000 |
Description
*Summary:*
When a Titanium blob references a non-file type, such as a byte buffer or "content://" URL, then the blob's imageAs*()
methods will ignore a JPEG's EXIF orientation setting.
This affects the following methods:
* Blob.imageAsCropped()
* Blob.imageAsResized()
* Blob.imageAsThumbnail()
* Blob.imageWithAlpha()
* Blob.imageWithRoundedCorner()
* Blob.imageWithTransparentBorder()
*Steps to reproduce:*
Build the attached [^DownloadImageBlobTest.js] on Android.
Tap on the "Download" button. (Requires Internet access.)
Tap on "JPEG - EXIF Rotate 90" in option dialog.
Notice that the displayed resized image is not upright. (This is the bug.
Do the same with all of the other "EXIF" options in the dialog. They all have this issue.
Attachments
It's an issue with blobs that do *not* wrap a file system path. That is, blobs which wrap a "content://" URL (like in above test case) or when the blobs wraps an in-memory image. *Solution:* In our
TiBlob.java
code, we have method calls toTiImageHelper.getOrientation()
which fetch the EXIF orientation from a JPEG. Instead of passing a file path to it, we should pass anInputStream
to it instead. https://github.com/jquick-axway/titanium_mobile/blob/master/android/titanium/src/java/org/appcelerator/titanium/TiBlob.javaBelow is [~smohammed]'s original ticket summary. Th below can reproduce this issue when taking a camera shot on a Pixel XL device and then calling
imageAsResized()
. Not all devices can reproduce it this way though since some camera will always save the photo in the upright position... and some won't and will write the orientation to the JPEG's EXIF data instead. *+Test Case:+* *index.js**index.xml*
*Test Steps*
Download SDK version 9.0.2.GA
Create an alloy application
Copy the test case above
Make sure camera permissions are enabled
Run the application on a Pixel XL
Take a picture in portrait mode
Check log for the orientation (width, height)
*Expected result* Console should log the correct orientation (350, 300) in this case *Actual result* The orientation is flipped and displayed as (300, 350)PR (master): https://github.com/appcelerator/titanium_mobile/pull/11679
FR Passed. Waiting for Jenkins build
merged to master for 9.1.0 target
*Closing ticket*. Improvement verified in SDK version
9.1.0.v20200810120239
. *Test and other information can be found at:* https://github.com/appcelerator/titanium_mobile/pull/11679