We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
After taking a photo from my LG G7 and starting Croppy from the file Uri, CroppyActivity started with the image rotated.
You may consider checking ExifInterface orientation before loading bitmap.
Sample code in Java :
Bitmap rotateBitmap(@NonNull String src, Bitmap bitmap) { int orientation; try { orientation = getExifOrientation(src); } catch (IOException e) { e.printStackTrace(); return bitmap; } Matrix matrix = new Matrix(); switch (orientation) { case ExifInterface.ORIENTATION_FLIP_HORIZONTAL: matrix.setScale(-1, 1); break; case ExifInterface.ORIENTATION_ROTATE_180: matrix.setRotate(180); break; case ExifInterface.ORIENTATION_FLIP_VERTICAL: matrix.setRotate(180); matrix.postScale(-1, 1); break; case ExifInterface.ORIENTATION_TRANSPOSE: matrix.setRotate(90); matrix.postScale(-1, 1); break; case ExifInterface.ORIENTATION_ROTATE_90: matrix.setRotate(90); break; case ExifInterface.ORIENTATION_TRANSVERSE: matrix.setRotate(-90); matrix.postScale(-1, 1); break; case ExifInterface.ORIENTATION_ROTATE_270: matrix.setRotate(-90); break; default: return bitmap; } try { Bitmap oriented = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); bitmap.recycle(); return oriented; } catch (OutOfMemoryError e) { e.printStackTrace(); return null; } } private int getExifOrientation(@NonNull String src) throws IOException { DebugLog.write(); ExifInterface exifInterface = new ExifInterface(src); return exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); }
The text was updated successfully, but these errors were encountered:
Done. Use version 0.2
0.2
Sorry, something went wrong.
No branches or pull requests
After taking a photo from my LG G7 and starting Croppy from the file Uri, CroppyActivity started with the image rotated.
You may consider checking ExifInterface orientation before loading bitmap.
Sample code in Java :
The text was updated successfully, but these errors were encountered: