google / cameraview

[DEPRECATED] Easily integrate Camera features into your Android app
Apache License 2.0
4.74k stars 1.03k forks source link

Image is rotated for some devices #208

Open sitannsu opened 6 years ago

sitannsu commented 6 years ago

How to detect if image rotated for some devices. For some devices like samsung image is auto rotatted after photo taken.

peter-haiduchyk commented 6 years ago

bug with 5 years history. Main problem its - samsung saves photo always in landscape mode . Say i make photo in portrate with size: w=1000 h = 1900. But saved photo will be with w=1900 h = 1000. If go to landscape than everything fine. Only bug with portrate mode. Im trying to fix this second day.

RationalRank commented 6 years ago

@petergayduchik Did you find a hack for it?

peter-haiduchyk commented 6 years ago

@sranjith096 https://stackoverflow.com/questions/47261434/photo-rotated-from-camera-samsung-device/47261631?noredirect=1#comment81474720_47261631 here a my solution . Not sure its will work on all devices.

zweinz commented 6 years ago

I'm also finding this to be the case on a new Pixel 2. Any updates on this issue?

MoustafaElsaghier commented 6 years ago

I've fixed this issue by checking the width and height of the image After long of debugging, I've found that the image is rotated by 90 degrees on devices like Samsung and sony so I've implemented this simple method for solving that issue, hope it solves yours

private static int fixOrientation(Bitmap bitmap, boolean isPortraite) {
        if (isPortraite) { 
            if (bitmap.getWidth() > bitmap.getHeight()) {
                return 90;
            }
        } else if (bitmap.getWidth() < bitmap.getHeight()) {
            return 90;
        }
        return 0;
    }

if any one need clearfication for this issue I 'm here

tomasmaks commented 6 years ago

MoustafaElsaghier your solution worked for me, gratz!

MoustafaElsaghier commented 6 years ago

@tomasmaks it's pleasure for me that it works with you.

Vico231088 commented 6 years ago

como puedo llamar a este metodo para que se ejecute 👍 private static int fixOrientation(Bitmap bitmap, boolean isPortraite) { if (isPortraite) { if (bitmap.getWidth() > bitmap.getHeight()) { return 90; } } else if (bitmap.getWidth() < bitmap.getHeight()) { return 90; } return 0; }