-
Notifications
You must be signed in to change notification settings - Fork 1k
Wrong picture orientation on Samsung devices #22
Comments
LG-K500h (X screen) has the same behaviour, after the photo is taken, is rotated 90 degrees to the left. |
This is because Samsung (also Sony) devices write EXIF orientation = 6 but |
Did someone find a workaround ? |
I've created pull request[https://github.com//pull/45/files] which adds option to have, as result, byte array and angle of image so u can easily rotate bitmap. All u have to do is copy I've tested it on samsung galaxy s6/nexus5 and it does work for me. |
is anyone gonna fix this ? |
I don't think this is a issue with the library anymore, the application should be in charge of rotating the image if necessary by reading the image Exif data. This can be easily achieved using the new Exif support library The exif library allows you to easily find out how much you have to rotate the image before you display it to the user. This is how it could be done: @Override
public void onPictureTaken(CameraView cameraView, byte[] data) {
// Find out if the picture needs rotating by looking at its Exif data
ExifInterface exifInterface = new ExifInterface(new ByteArrayInputStream(data));
int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1);
int rotationDegrees = 0;
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_90:
rotationDegrees = 90;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
rotationDegrees = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_270:
rotationDegrees = 270;
break;
}
// Create and rotate the bitmap by rotationDegrees
} I think this issue can be closed now. |
its still not working . more than 5 years. And bug still here. I cant believe it . Samsungs devices have a lot of bugs. I cant understand why they cant fix this problem. |
you should follow @ivacf comment #22 (comment) |
@ivacf I am using this code. I am unable get the ExifInterface object, I get a FileNotFoundException. Whereas, if I am using the same file to upload the image to my S3 bucket and that is successful. Can you please let me know why the ExifInterface object is not getting the File from the File path?
|
@ivacf does your code require API level 24? add this stage i'm just considering screenshotting the fking viewfinder. the camera api drives me nuts |
fix NPE crash with onMeasure when previewSize is null
* New tests * Try adjust codecov * CropHelper and CameraUtils tests * Set target coverage to 40% * OrientationHelperTest * Preview tests * Fix SurfaceView * Introduce Task for async tests * Gesture tests * Improve Gesture Tests * Add wake lock * Fix view size * Add build info logs * Revert info * Try fix bug * Test timeout * Try fix tests * Fix TextureView tests if not hardware accelerated * Fix bug
Solved on Samsung and sony devices (tested devices). I've solved this issue by checking if the width > height of the image then rotate by 90
then I call this method to apply the rotation if needed
the reason why I set scale by (-1,1) because I use front camera and need to fix the refliction issue of camera. hope this solves the issue you have. |
@MoustafaElsaghier - Thanks for this solution. I have implemented this and tested. Working good on Samsung J pro but image turns upside down(i.e. 180 degree) in Samsung J Core. Don't know why it is. Please suggest a solution. |
@MrBrown09 sorry for the late answer the same with 270 and 90. if you need any help how calc angel tell me, please |
关键原因:bitmap 不包含 exif 信息
解决方法2:读取 exif 信息,按 exif 信息旋转,最后一定不能再写入原来的ExifInterface.TAG_ORIENTATION的值,该值旋转后应该为0。
|
You need to add default state in switch case with for Samsung and Sony device. below is a working code. @OverRide
} |
anyone fixed this bullshit for samsung android 8 + ?? (for example on samsung s8 with OS 8.0 + its stilll returned bad rotation) |
@petergayduchik able to solve the issue by this. you have to rotate image by 90 degree. have to add default case handling `[@OverRide
}](url)` |
i hate developers on Samsung side . It's perfect idiotism . From Gallery : |
I have the same problem bug it is for face detection with camera2 API, my app is blocked in portrait mode and I don't now why, with a samsung Galaxy note 8, face detection only work in landscape mode... Do someone know how to fix it ? |
@Bonten156 I came across this blog, might be helpful for you. https://medium.com/@kenodoggy/solving-image-rotation-on-android-using-camera2-api-7b3ed3518ab6 |
Anyone fixed this in Android 11 Samsung Device? |
1 similar comment
no but now am using https://github.com/Dhaval2404/ImagePicker this library and its working fine for Samsung devices too |
Hi,
After taking a picture with this library I create a Bitmap and set it in an ImageView as follow:
This works fine on a Nexus 5X, however on Samsung devices the picture orientation appears to be incorrectly rotated 90 degrees to the left when the device orientation is portrait. Is there a way to fix this issue?
The text was updated successfully, but these errors were encountered: