Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7412723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:35:10+00:00 2026-05-29T06:35:10+00:00

I am using gallery picker for picking an image from gallery. The photos taken

  • 0

I am using gallery picker for picking an image from gallery. The photos taken by the camera in portrait mode is shown in the gallery as straight. But when I import the photos, i get the photo as rotated (landscape). Only gallery is showing this picture as straight. How to manage this problem? I want all photos as its actual orientation.
Thanks in advance

private void addImageFromGallery() {

    Intent intent = new Intent();
    intent.setType("image/*");
    intent.setAction(Intent.ACTION_GET_CONTENT);
    startActivityForResult(Intent.createChooser(intent, "Select Picture"),
            GALLERY_CODE);

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:35:11+00:00Added an answer on May 29, 2026 at 6:35 am

    Got the answer. The orientation is saved with the image in EXIF format. We have to read the Orientation tag of the data for each image..

    public static float rotationForImage(Context context, Uri uri) {
            if (uri.getScheme().equals("content")) {
            String[] projection = { Images.ImageColumns.ORIENTATION };
            Cursor c = context.getContentResolver().query(
                    uri, projection, null, null, null);
            if (c.moveToFirst()) {
                return c.getInt(0);
            }
        } else if (uri.getScheme().equals("file")) {
            try {
                ExifInterface exif = new ExifInterface(uri.getPath());
                int rotation = (int)exifOrientationToDegrees(
                        exif.getAttributeInt(ExifInterface.TAG_ORIENTATION,
                                ExifInterface.ORIENTATION_NORMAL));
                return rotation;
            } catch (IOException e) {
                Log.e(TAG, "Error checking exif", e);
            }
        }
            return 0f;
        }
    
        private static float exifOrientationToDegrees(int exifOrientation) {
        if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_90) {
            return 90;
        } else if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_180) {
            return 180;
        } else if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_270) {
            return 270;
        }
        return 0;
    }
    }
    

    The rotation value can be used to correct a photo’s orientation as follows:

    Matrix matrix = new Matrix();
    float rotation = PhotoTaker.rotationForImage(context, uri);
    if (rotation != 0f) {
          matrix.preRotate(rotation);
     }
    
    Bitmap resizedBitmap = Bitmap.createBitmap(
     sourceBitmap, 0, 0, width, height, matrix, true);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using image picker to pick image from gallery in iPhone device. I
i need to upload a image from iphone gallery ,but i am not getting
I am using following code to pick image from gallery public void takePhotoFromLibrary() {
I am fetching Uri of a image from gallery using Intent intent = new
I want to create a video gallery using Masonry on my website but I'm
I am using the fancybox.I want to display the image gallery using the galleria
I am trying to make an image gallery using jquery and html5. I am
I am using sigplus image gallery extension for JOomla and sometimes I need to
I'm using simple gallery script which dynamically loads image when user clicks on thumbnail
I'm using original Gallery app from the ICS source code. And Now the thing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.