Android image picking issue from gallery
<p>I'm new to android and I'm developing an app which uses gallery and image picking from gallery, but I'm getting an error which I have tried to solve in different way,as</p>

<p>I'm using gallery located on SD card when I pick the horizontal image (width greater than height) it loads the image in image view perfectly fine but the problem is with vertical image (height greater than width) it show the image in image view rotated on the left side(or saying -90 degree from original position). I have printed the width and height of the both images (horizontal and vertical) its show width=2592 and height=1936 for both images,</p>

<p>I'm really struck here and haven't able to solve it for about 3 weeks please anyone help me.</p>

<p>Thanks in advance</p>

<p>here is my code:</p>

<p>for starting gallery intent</p>

<pre><code>Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
startActivityForResult(i, ACTIVITY_SELECT_IMAGE);
</code></pre>

<p>after selecting Image:</p>

<pre><code>protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent)
{
        super.onActivityResult(requestCode, resultCode, imageReturnedIntent);
        try{ switch(requestCode) { case REQ_CODE_PICK_IMAGE: if(resultCode == RESULT_OK)
        {
            Uri selectedImage = imageReturnedIntent.getData(); String[] filePathColumn = {MediaStore.Images.Media.DATA};

            Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
            cursor.moveToFirst();

            int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
            filePath = cursor.getString(columnIndex);
            cursor.close();

            File img = new File(filePath); Bitmap yourSelectedImage =  BitmapFactory.decodeStream(new FileInputStream(img));
            int imgHeight = yourSelectedImage.getHeight(); int imgWidth = yourSelectedImage.getWidth();
            Toast.makeText(getApplicationContext(), "Original size: Width ="+imgWidth+" Height="+imgHeight, Toast.LENGTH_LONG).show();
            float myScalingFactor = MyScaleFactor(imgHeight,imgWidth);
            int destW = (int)(imgWidth*myScalingFactor);
            int destH = (int)(imgHeight*myScalingFactor);
            Toast.makeText(getApplicationContext(), "Scaled size: Width ="+destW+" Height="+destH + "Scale" +myScalingFactor, Toast.LENGTH_LONG).show();
            yourSelectedImage = Bitmap.createScaledBitmap(yourSelectedImage, destW, destH, true);
            picUpload.setImageBitmap(yourSelectedImage);
}
</code></pre>
