cameraview icon indicating copy to clipboard operation
cameraview copied to clipboard

Image is rotated for some devices

Open sitannsu opened this issue 8 years ago • 8 comments

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

sitannsu avatar Oct 03 '17 17:10 sitannsu

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.

peter-haiduchyk avatar Nov 14 '17 09:11 peter-haiduchyk

@petergayduchik Did you find a hack for it?

RationalRank avatar Nov 20 '17 14:11 RationalRank

@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.

peter-haiduchyk avatar Nov 21 '17 08:11 peter-haiduchyk

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

zweinz avatar Jan 26 '18 18:01 zweinz

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

MoustafaElsaghier avatar Apr 25 '18 11:04 MoustafaElsaghier

MoustafaElsaghier your solution worked for me, gratz!

tomasmaks avatar May 29 '18 09:05 tomasmaks

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

MoustafaElsaghier avatar May 29 '18 15:05 MoustafaElsaghier

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; }

Vico231088 avatar Sep 07 '18 17:09 Vico231088