Pictures taken with Camera - orientation / rotation
I let users take an image from the camera or the photo gallery and upload them to an online album - everything works flawlessly expect for that photos captured in portrait mode (vertical) are showing up sideways / landscape. How do you know what orientation the photo was taken at? Is there away to automatically handle the rotation?
11 Answers
-
I have come up with a solution that seems to be working. After I take the photo, I create a new ImageView with the results of the camera/photogallery action. I then do some scaling there - and use the imageView.getImage() to get the image that I send to my server. This method gives me the picture how it was taken by the camera…
-
I also have this question. The thing i did was to check the size of the picture, if you do that you can see if it's taken in landscape mode or portrait. But i really think it's bad to relay on the size of the image, it should be some other way?
-
On your server, you can also read the EXIF data (there are plenty of libraries out there for many languages) where you can see the orientation used in the photo.
Then it's pretty simple to write code to rotate the incoming image file on your server. (again, there are plots of examples out there on how to do this in various languages)
But I do agree that it would be great to have this data available beforehand.
Also, it would be great to have some basic imageBlob manipulation for this within Titanium.
tht,
kossops: just wait until you have to detect orientation of video! sheesh! that took me ages to solve! :)
-
Hey Brandon - Just curious if you (or anyone else) made any further headway with this.
I have tried the same solution with the following code:
Titanium.Media.showCamera({ success:function(e){ var img = Ti.UI.createImageView({ image: e.media, transform: Ti.UI.create2DMatrix().rotate(90) }); uploadImageToServer(img.toImage()); //psuedocode } });
the problem i get is that the rotation is OK but the image is completely skewed in terms of diminsions - it actually looks squished.
Anyone have any thoughts?
-
I cannot explain why, but this works for me no matter how I hold the camera.
success:function() { var imageFile = event.media; var imageAsTaken = Ti.UI.createImageView({ image: imageFile }); imageFile = imageAsTaken.toImage(); // do other processing... },
I would love to know how this works.
-
I encountered this problem when resizing images on android. When resizing images on Android, the EXIF data gets lost. Titanium then assumes that pictures are taken in landscape mode, which means that you image will be rotated. The ImageView approach is something that helps for some, however not for me, so I had to make a rotation tool.
-
– BUMP –
was this issue ever resolved in the framework -
Can anyone post working code for this? I have been fighting with getting the image orientation and size set properly to display… a working sample would be appreciated.
-
Bump….
anyone have this working yet and willing to share an example?
thanks…
~Brian -
Also very interested in this.
It would also help to just be able to read the EXIF data of the image.
My images come from a camera, are not taken with the device itself.Thanks for any help!
-
There is a exif library in javascript.