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 9183009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:41:50+00:00 2026-06-17T18:41:50+00:00

The only allowed orientation in my app is landscape. I force this in the

  • 0

The only allowed orientation in my app is landscape. I force this in the project properties under target > summery and only allow portrait in shouldAutorotateToInterfaceOrientation

The problem is when I take a picture while holding the phone horizontally (landscape), the photo will be taken in landscape orientation, while the UI remains in portrait mode.

This means in landscape mode I get a wide image of 3264 x 2448 instead of the tall image (2448 x 3264) I get in portrait mode.

Next the user can crop the image, but if the image is taken in landscape mode I get very ugly stretched images. Adding borders or switching the UI to landscape is not an option.

Is there a way to force the UIImagePickerController to take a photo in portrait dimensions even though the phone is held horizontally (landscape mode)?

I initialize the UIImagePickerController with the following settings:

    imagePicker =[[UIImagePickerController alloc] init];
    imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
    imagePicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
    imagePicker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
    imagePicker.showsCameraControls = NO;
    imagePicker.modalPresentationStyle = UIModalPresentationFullScreen;
    imagePicker.wantsFullScreenLayout = YES;
    imagePicker.cameraViewTransform = CGAffineTransformScale(imagePicker.cameraViewTransform,CAMERA_TRANSFORM, CAMERA_TRANSFORM);
    imagePicker.navigationBarHidden = YES;
    imagePicker.toolbarHidden = YES;
    [self presentModalViewController:imagePicker animated:NO];
    imagePicker.cameraOverlayView = self.cameraOverlay;
    imagePicker.cameraFlashMode = UIImagePickerControllerCameraFlashModeOff;
  • 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-06-17T18:41:52+00:00Added an answer on June 17, 2026 at 6:41 pm

    The imageOrientation flag is set on the UIImage depending on which way up the camera is being held when the picture is taken. This is a read-only flag and determines the orientation that iOS will attempt to display the image when you place it into a view.

    You could check the orientation before displaying the image, and manipulate the imageView accordingly. Assuming you have an imageView enclosed inside a same-sized view…

    - (void) imagePickerImage:(UIImage*)image
    {
        if (image.imageOrientation == UIImageOrientationUp ) {
            self.imageView.bounds = CGRectMake
               (0, 0, self.view.bounds.size.height, self.view.bounds.size.width);
            self.imageView.transform = CGAffineTransformMakeRotation(M_PI/2);
    
        } else if (image.imageOrientation == UIImageOrientationDown) {
            self.imageView.bounds = CGRectMake
               (0, 0, self.view.bounds.size.height, self.view.bounds.size.width);
            self.imageView.transform = CGAffineTransformMakeRotation(-M_PI/2);
        }
        else {
            self.imageView.bounds = self.view.bounds;
            self.imageView.transform = CGAffineTransformIdentity;
        }
        self.imageView.image = image;
    }
    

    Another option could be to create a new image from an imageRep: this should strip out the orientation information.

    update
    The native pixel dimensions of an iPhone photograph are landscape, regardless of the way the phone is held when it is taken. It is only the orientation EXIF flag that is set differently. You cannot alter the EXIF flag but you can strip it out by copying the image bitmap data to a new bitmap image. See also my answers here.

    Here is a way to strip out the EXIF data and add in a portrait EXIF flag. You are creating a new UIImage and setting the EXIF flag as you create it. You could use this to flag your landscape images as portrait (UIImageOrientationRight).

    - (UIImage*)stripExif:(UIImage*)image
    {
        CGImageRef cgImage = image.CGImage;
        UIImage* result = [UIImage imageWithCGImage:cgImage scale:1 
                                        orientation:UIImageOrientationRight];
        return result;
    }
    

    update 2
    It is misleading to refer to the imageOrientation property of UIImage as an EXIF flag, for two reasons:

    (1) image metadata is stored in a dictionary-style structure, within which can be a number of sub-dictionaries, one of which is EXIF. Others include TIFF, IPTC, PNG for example. There is also a general set of tags at the top-level dictionary. The orientation key is NOT in the EXIF section, it is found in the TIFF and IPTC subdictionaries (if present) and also as a top-level key. We tend to use the term EXIF when referring to image metadata as a whole but this is misleading.

    (2) Orientation metadata in the image file uses a different set of flag conventions to those that Apple uses in their UIImage.imageOrientation property. Therefore you have to take care if reading this property in order to display the image correctly. Apple evidently uses the image file’s orientation metadata to set the UIImage’s property, but there is a bit of translation going on.

     Orientation 
    
     Apple/UIImage.imageOrientation     Jpeg/File kCGImagePropertyOrientation
    
        UIImageOrientationUp    = 0  =  Landscape left  = 1
        UIImageOrientationDown  = 1  =  Landscape right = 3
        UIImageOrientationLeft  = 2  =  Portrait  down  = 8
        UIImageOrientationRight = 3  =  Portrait  up    = 6
    

    Here is a page showing ‘exif’ rotation flags. Compare with Apple’s UIImage documentation (constants section). See also Apple’s CGImageProperties_Reference, especially kCGImagePropertyOrientation

    I have loaded a small project onto github logging various UIImage metadata issues

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My app only supports landscape orientations via the supportedInterfaceOrientation properties. Using an iOS prior
I want to make my App landscape only, so I am using the method
I need a way to force the orientation back to portrait on rotate. The
This is the assigment. I believe I am only allowed to use If and
I am only allowed to use private members in the programming course I'm taking,
How do I create a MS SQL server user that only allowed to read
I need some help with a textbox: The textbox is only allowed to contain
I have a requirement that a user is allowed only to enter string value
I have an asmx web service that should only be allowed to respond to
W3 specifies that only four CSS rules are allowed for table columns (with the

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.