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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:53:56+00:00 2026-05-23T08:53:56+00:00

I have this iPhone application that let users take a picture and save it

  • 0

I have this iPhone application that let users take a picture and save it in a database online. My problem is that every time an user take a picture and saves it, the picture results to be in landscape, even though it was taken in portrait mode. This results in having the portrait picture stretched.

This is the code I use when taking a picture:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    [picker dismissModalViewControllerAnimated:YES];

    NSData *imgData=UIImageJPEGRepresentation([info objectForKey:@"UIImagePickerControllerOriginalImage"],1);
    UIImage *img=[[UIImage alloc] initWithData:imgData];

    if(img.size.width < img.size.height){
        NSLog(@"width < height");
        imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
    }
    else{
        NSLog(@"width > height");
        imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 460, 320)];
    }

    imageView.image = img;
    [img release];
    [[self view] fillPreviewWithImg: imageView];
    [[self view] setImage: imageView.image];
}

Basically what I do is take the picture, create a UIImage, check if it’s portrait or landscape, create the corresponding UIImageView and then set the image into the UIImageView. After that I just call a couple of methods to set up the image in the main view.

I believe the problem with stretching is not bounded to the PHP but to the Objective-C code, but I can’t really see how or why this behavior happens.

Does anyone of you have an idea?

Thanks,

Masiar

  • 1 1 Answer
  • 2 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-23T08:53:56+00:00Added an answer on May 23, 2026 at 8:53 am

    Have a look at the imageOrientation property of the UIImage class. You can have an image that is 320 wide and 480 high, but with an orientation of Landscape. This is contained in the EXIF information and it is up to the viewing program to use this orientation information to rotate the image appropriately. Just checking the width and height of the image is not sufficient to know the orientation and this is causing your stretching that you are seeing.

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

Sidebar

Related Questions

I have developed an iPhone application that was rejected. With this application I offer
My question is this: I have an application designed for iPhone and I decided
I have some query. First of all let's have an iPhone application flow which
Hello guys, I have a general design problem with iPhone application. I want to
I am working on an iPhone application that runs in portrait mode only. This
For an iPhone application I need to request data from an online database. I
Let's say I have a folder in my Resources folder of my iPhone application
I have a memory management-related question in a multithreaded iPhone application. Let's say we
I have an iPhone application that makes use of an API. Among the API
I have this chronic issue with iPhone UI development where views sometimes seem to

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.