Android Images Rotated

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Android Images Rotated

Erik J. Thomas
Hey all:

I'm allowing a user to take a profile selfie or import a file from their camera roll, and on Android, the images are rotated inconsistently between front and rear cameras, as well as when importing from camera roll depending on how the user held the camera.


The MediaEvent (upon selecting an image) and MediaPromise object (data) does not provide any orientation information and the image's sourceWidth is ALWAYS larger than sourceHeight no matter which camera or mode (portrait/landscape) was used to take the picture. So there is no way to know how much to rotate the image.

My problem is:
  • I need to know if a photo taken with CameraUI was front or back camera.
  • I need to know if a photo imported using CameraRoll was originally taken with front or back camera, and whether the user held the camera in portrait or landscape mode. 
Each of these variables result in different rotations of the image and I need to correct the rotation (that's easy) once I know by how much it's off.

I don't have any problem on iOS at all. Apple is consistent. I'm figuring I'll have to give my users the ability to manually rotate their pics, or write an ANE or something else hard to do just to get more information about the images on Android.

Any ideas?

Thanks.

Erik



Reply | Threaded
Open this post in threaded view
|

Re: Android Images Rotated

leokan23
Hi,

I had similar problems to one of our shelfie apps. I solved the problem on android using the following code:

https://pastebin.com/f1NvTyLD

This code only uses the front camera and rotates it to work for Android.

An alternative could also be Camera ANE from distriqt.

Hope this helps
Reply | Threaded
Open this post in threaded view
|

Re: Android Images Rotated

Paul Moreau
I had the same issue and solved it by using this library to get the
ExifInfo of the image and getting the true orientation from that:

https://github.com/cantrell/ExifExample

However I have since received a report from an Android 7 user complaining
of orientation issues that I haven't had time to investigate yet but aside
from that it works perfectly.

Paul


On Tue, Jun 13, 2017 at 10:55 AM, leokan23 <[hidden email]> wrote:

> Hi,
>
> I had similar problems to one of our shelfie apps. I solved the problem on
> android using the following code:
>
> https://pastebin.com/f1NvTyLD <https://pastebin.com/f1NvTyLD>
> This code only uses the front camera and rotates it to work for Android.
>
> An alternative could also be Camera ANE from distriqt.
>
> Hope this helps
>
>
>
> --
> View this message in context: http://apache-flex-users.23333
> 46.n4.nabble.com/Android-Images-Rotated-tp15306p15309.html
> Sent from the Apache Flex Users mailing list archive at Nabble.com.
>



--






*DISCLAIMER: This electronic message together with any attachments is
confidential. If you are not the intended recipient, do not copy, disclose
or use the contents in any way. Please also advise us by return e-mail that
you have received the message and then please destroy. Zutec  Ltd is not
responsible for any changes made to this message and / or any attachments
after sending by Zutec. We use virus scanning software but exclude all
liability for viruses or anything similar in this email or any attachment.*
Reply | Threaded
Open this post in threaded view
|

Re: Android Images Rotated

Erik J. Thomas
In reply to this post by leokan23
Hey leokan23:

I was trying to avoid using Camera since CameraUI provides so much free functionality. If I can find no other way, I'll use this pattern as you suggested instead of CameraUI.

Thanks!

Erik

> On Jun 13, 2017, at 2:55 AM, leokan23 <[hidden email]> wrote:
>
> Hi,
>
> I had similar problems to one of our shelfie apps. I solved the problem on
> android using the following code:
>
> https://pastebin.com/f1NvTyLD <https://pastebin.com/f1NvTyLD>  
> This code only uses the front camera and rotates it to work for Android.
>
> An alternative could also be Camera ANE from distriqt.
>
> Hope this helps
>
>
>
> --
> View this message in context: http://apache-flex-users.2333346.n4.nabble.com/Android-Images-Rotated-tp15306p15309.html
> Sent from the Apache Flex Users mailing list archive at Nabble.com.
>

Reply | Threaded
Open this post in threaded view
|

Re: Android Images Rotated

Erik J. Thomas
In reply to this post by Paul Moreau
Hey Paul:

Thanks for your suggestion. This approach looks promising.

Erik

> On Jun 13, 2017, at 3:45 AM, Paul Moreau <[hidden email]> wrote:
>
> I had the same issue and solved it by using this library to get the
> ExifInfo of the image and getting the true orientation from that:
>
> https://github.com/cantrell/ExifExample
>
> However I have since received a report from an Android 7 user complaining
> of orientation issues that I haven't had time to investigate yet but aside
> from that it works perfectly.
>
> Paul
>
>
> On Tue, Jun 13, 2017 at 10:55 AM, leokan23 <[hidden email]> wrote:
>
>> Hi,
>>
>> I had similar problems to one of our shelfie apps. I solved the problem on
>> android using the following code:
>>
>> https://pastebin.com/f1NvTyLD <https://pastebin.com/f1NvTyLD>
>> This code only uses the front camera and rotates it to work for Android.
>>
>> An alternative could also be Camera ANE from distriqt.
>>
>> Hope this helps
>>
>>
>>
>> --
>> View this message in context: http://apache-flex-users.23333
>> 46.n4.nabble.com/Android-Images-Rotated-tp15306p15309.html
>> Sent from the Apache Flex Users mailing list archive at Nabble.com.
>>
>
>
>
> --
>
>
>
>
>
>
> *DISCLAIMER: This electronic message together with any attachments is
> confidential. If you are not the intended recipient, do not copy, disclose
> or use the contents in any way. Please also advise us by return e-mail that
> you have received the message and then please destroy. Zutec  Ltd is not
> responsible for any changes made to this message and / or any attachments
> after sending by Zutec. We use virus scanning software but exclude all
> liability for viruses or anything similar in this email or any attachment.*

Reply | Threaded
Open this post in threaded view
|

Re: Android Images Rotated

Erik J. Thomas
Hey Paul:

Your suggestion solves my problem perfectly! The exif info gives me an "Orientation" property that is either 1,3, 6 or 8 for the four possible camera orientations when taking a photo, so I am able to rotate the image to be upright in all cases. Wonderful!

Thanks so much!

Erik

> On Jun 13, 2017, at 8:18 AM, Erik J. Thomas <[hidden email]> wrote:
>
> Hey Paul:
>
> Thanks for your suggestion. This approach looks promising.
>
> Erik
>
>> On Jun 13, 2017, at 3:45 AM, Paul Moreau <[hidden email]> wrote:
>>
>> I had the same issue and solved it by using this library to get the
>> ExifInfo of the image and getting the true orientation from that:
>>
>> https://github.com/cantrell/ExifExample
>>
>> However I have since received a report from an Android 7 user complaining
>> of orientation issues that I haven't had time to investigate yet but aside
>> from that it works perfectly.
>>
>> Paul
>>
>>
>> On Tue, Jun 13, 2017 at 10:55 AM, leokan23 <[hidden email]> wrote:
>>
>>> Hi,
>>>
>>> I had similar problems to one of our shelfie apps. I solved the problem on
>>> android using the following code:
>>>
>>> https://pastebin.com/f1NvTyLD <https://pastebin.com/f1NvTyLD>
>>> This code only uses the front camera and rotates it to work for Android.
>>>
>>> An alternative could also be Camera ANE from distriqt.
>>>
>>> Hope this helps
>>>
>>>
>>>
>>> --
>>> View this message in context: http://apache-flex-users.23333
>>> 46.n4.nabble.com/Android-Images-Rotated-tp15306p15309.html
>>> Sent from the Apache Flex Users mailing list archive at Nabble.com.
>>>
>>
>>
>>
>> --
>>
>>
>>
>>
>>
>>
>> *DISCLAIMER: This electronic message together with any attachments is
>> confidential. If you are not the intended recipient, do not copy, disclose
>> or use the contents in any way. Please also advise us by return e-mail that
>> you have received the message and then please destroy. Zutec  Ltd is not
>> responsible for any changes made to this message and / or any attachments
>> after sending by Zutec. We use virus scanning software but exclude all
>> liability for viruses or anything similar in this email or any attachment.*
>

Reply | Threaded
Open this post in threaded view
|

Re: Android Images Rotated

Paul Moreau
Thats great Erik, happy to help.

On Tue, Jun 13, 2017 at 6:49 PM, Erik J. Thomas <[hidden email]> wrote:

> Hey Paul:
>
> Your suggestion solves my problem perfectly! The exif info gives me an
> "Orientation" property that is either 1,3, 6 or 8 for the four possible
> camera orientations when taking a photo, so I am able to rotate the image
> to be upright in all cases. Wonderful!
>
> Thanks so much!
>
> Erik
>
> > On Jun 13, 2017, at 8:18 AM, Erik J. Thomas <[hidden email]> wrote:
> >
> > Hey Paul:
> >
> > Thanks for your suggestion. This approach looks promising.
> >
> > Erik
> >
> >> On Jun 13, 2017, at 3:45 AM, Paul Moreau <[hidden email]> wrote:
> >>
> >> I had the same issue and solved it by using this library to get the
> >> ExifInfo of the image and getting the true orientation from that:
> >>
> >> https://github.com/cantrell/ExifExample
> >>
> >> However I have since received a report from an Android 7 user
> complaining
> >> of orientation issues that I haven't had time to investigate yet but
> aside
> >> from that it works perfectly.
> >>
> >> Paul
> >>
> >>
> >> On Tue, Jun 13, 2017 at 10:55 AM, leokan23 <[hidden email]> wrote:
> >>
> >>> Hi,
> >>>
> >>> I had similar problems to one of our shelfie apps. I solved the
> problem on
> >>> android using the following code:
> >>>
> >>> https://pastebin.com/f1NvTyLD <https://pastebin.com/f1NvTyLD>
> >>> This code only uses the front camera and rotates it to work for
> Android.
> >>>
> >>> An alternative could also be Camera ANE from distriqt.
> >>>
> >>> Hope this helps
> >>>
> >>>
> >>>
> >>> --
> >>> View this message in context: http://apache-flex-users.23333
> >>> 46.n4.nabble.com/Android-Images-Rotated-tp15306p15309.html
> >>> Sent from the Apache Flex Users mailing list archive at Nabble.com.
> >>>
> >>
> >>
> >>
> >> --
> >>
> >>
> >>
> >>
> >>
> >>
> >> *DISCLAIMER: This electronic message together with any attachments is
> >> confidential. If you are not the intended recipient, do not copy,
> disclose
> >> or use the contents in any way. Please also advise us by return e-mail
> that
> >> you have received the message and then please destroy. Zutec  Ltd is not
> >> responsible for any changes made to this message and / or any
> attachments
> >> after sending by Zutec. We use virus scanning software but exclude all
> >> liability for viruses or anything similar in this email or any
> attachment.*
> >
>
>


--






*DISCLAIMER: This electronic message together with any attachments is
confidential. If you are not the intended recipient, do not copy, disclose
or use the contents in any way. Please also advise us by return e-mail that
you have received the message and then please destroy. Zutec  Ltd is not
responsible for any changes made to this message and / or any attachments
after sending by Zutec. We use virus scanning software but exclude all
liability for viruses or anything similar in this email or any attachment.*