My app ask the user to take a photo and then saves it.
I have noticed that Samsung Galaxy S2 takes a portrait photo
but when I save it to the server I see it in landscape only in the server.
(even though it was taken in portrait).
It doesn't happen for me with other phones (Samsung S4, Nexus 5).
When I look at the photo gallery I see the photo in portrait.
Update
The weird thing is that in my java code it seemed to be portrait orientation
so I really don't get it:
if (getContext().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
//a
}else {
//b
}
But i saw something odd: the settings and other native dialog are all landscape when using S2 camera. see attachment:
Update2
I have checked exif.getAttributeInt(ExifInterface.TAG_ORIENTATION
and got 6 ( ExifInterface.ORIENTATION_ROTATE_90)
So i have tried to set this to ORIENTATION_ROTATE_270 or ORIENTATION_NORMAL
but it didn't help
ExifInterface exif;
try {
exif = new ExifInterface(imageFilename);
int orientation =
exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
exif.setAttribute(ExifInterface.TAG_ORIENTATION,
String.valueOf(ExifInterface.ORIENTATION_ROTATE_270));
exif.saveAttributes();
orientation =
exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
boolean b = orientation == Configuration.ORIENTATION_LANDSCAPE;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
You are right. The documentation of Camera.Parameters.setRotation() is very clear:
The camera driver may set orientation in the EXIF header without rotating the picture. Or the driver may rotate the picture and the EXIF thumbnail. If the Jpeg picture is rotated, the orientation in the EXIF header will be missing or 1 (row #0 is top and column #0 is left side).
The solution is to actually perform rotation of the pictures before upload, or maybe on the server (the choice depends on your product requirements). You can use a Java MediaUtil library, see eg https://stackoverflow.com/a/15302674/192373 .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.