Note that there are some explanatory texts on larger screens.

plurals
  1. POFacing Orientation issue with Camera captured image on Android phones
    text
    copied!<p>I am using exifInterface for photo rotation issue code is below: Facing captured image orientation issue from camera.</p> <ul> <li><strong>Create a Bitmap from the file</strong></li> </ul> <pre class="lang-java prettyprint-override"><code>Bitmap b = BitmapFactory.decodeFile(imagePath); </code></pre> <ul> <li><strong>Resize the Bitmap by scaling it to appropriate level</strong></li> </ul> <pre class="lang-java prettyprint-override"><code>int width = b.getWidth(); int height = b.getHeight(); int newWidth = 150; int newHeight = 150; float scaleWidth = ((float) newWidth) / width; float scaleHeight = ((float) newHeight) / height; Matrix matrix = new Matrix(); matrix.postScale(scaleWidth, scaleHeight); // Bitmap resizedBitmap = Bitmap.createBitmap(b, 0, 0, width, height, matrix, true); // resizedBitmap.compress(Bitmap.CompressFormat.JPEG, 70, out); </code></pre> <ul> <li><strong>Handle orientation of the image</strong></li> </ul> <pre class="lang-java prettyprint-override"><code> ExifInterface exif = new ExifInterface(imagePath); String orientation = exif.getAttribute(ExifInterface.TAG_ORIENTATION); if (orientation.equals(ExifInterface.ORIENTATION_NORMAL)) { // Do nothing. The original image is fine. } else if (orientation.equals(ExifInterface.ORIENTATION_ROTATE_90+"")) { matrix.postRotate(90); } else if (orientation.equals(ExifInterface.ORIENTATION_ROTATE_180+"")) { matrix.postRotate(180); } else if (orientation.equals(ExifInterface.ORIENTATION_ROTATE_270+"")) { matrix.postRotate(270); } </code></pre> <ul> <li><strong>Save the new bitmap</strong> </li> </ul> <pre class="lang-java prettyprint-override"><code> out = new FileOutputStream(new File("some output file path")); Bitmap resizedBitmap = Bitmap.createBitmap(b, 0, 0, width, height, matrix, true); resizedBitmap.compress(Bitmap.CompressFormat.JPEG, 70, out); </code></pre> <p>This code not working for resolve rotation issue, please give me guideline. On Lg devices it's exifinterface always returning 0 orientation, Samsung devices returning 6 and 1.</p> <p>How to fix this issue with all the devices like htc, Motorola, samsung , Sony and LG.</p> <p>I am thankful to you all please help me.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload