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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:06:01+00:00 2026-06-15T20:06:01+00:00

My application allows the user to take a picture in the camera/or choose from

  • 0

My application allows the user to take a picture in the camera/or choose from his photo library.

I would like the posted image to be in resolution 650X550

However I see:

After this code the size is 320X480

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
    {
        chosenImage = image;
        NSLog(@"The widht is %f",image.size.width);
        NSLog(@"The height is %f",image.size.height);
    }

When I submit the image like this – I retrieve it in 1024X480 on the server side

 NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://myurl/upload/"] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60];
    [request setHTTPMethod:@"POST"];
    NSMutableData *body = [NSMutableData data];
    NSString *boundary = @"---------------------------14737809831466499882746641449";
    NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];
    [request addValue:contentType forHTTPHeaderField:@"Content-Type"];
    NSData *imageData = UIImageJPEGRepresentation(appDelegate.chosenImage, 0.5);
    // file
    [body appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[@"Content-Disposition: form-data; name=\"file\"; filename=\"iphone.jpg\"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[@"Content-Type: application/octet-stream\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[NSData dataWithData:imageData]];
    [body appendData:[@"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
    // close form
    [body appendData:[[NSString stringWithFormat:@"--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
    // set request body
    [request setHTTPBody:body];

I would like to retrieve it as 650X550 – the size that I declared in objcetive-c – to my code on server side

When I try to submit to my backend code with a regular HTML page – it sends the original size of the image and not 1024X480.

How can I achieve retrieving an image in its original size?

  • 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-15T20:06:03+00:00Added an answer on June 15, 2026 at 8:06 pm

    you have no influence on the size you get from the picker — though it should be MUCH larger

    you can manually scale it before the upload

    #import <UIKit/UIKit.h>
    @interface UIImage (Resize)
    - (UIImage*)scaleToSize:(CGSize)size;
    @end
    
    @implementation UIImage (Resizing)
    
    - (UIImage*)scaleToSize:(CGSize)size {
        UIGraphicsBeginImageContext(size);
    
        CGContextRef context = UIGraphicsGetCurrentContext();
        CGContextTranslateCTM(context, 0.0, size.height);
        CGContextScaleCTM(context, 1.0, -1.0);
    
        CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, size.width, size.height), self.CGImage);
    
        UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext();
    
        UIGraphicsEndImageContext();
    
        return scaledImage;
    }
    @end
    

    DEMO:

    objc-side:

    UIImage *demo = [UIImage imageNamed:@"demo.jpg"];
    UIImage *scaledImage = [demo scaleToSize:CGSizeMake(650, 550)];
    
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://www.pich.info/test.php"] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60];
    [request setHTTPMethod:@"POST"];
    NSMutableData *body = [NSMutableData data];
    NSString *boundary = @"---------------------------14737809831466499882746641449";
    NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];
    [request addValue:contentType forHTTPHeaderField:@"Content-Type"];
    NSData *imageData = UIImageJPEGRepresentation(scaledImage, 0.5);
    // file
    [body appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[@"Content-Disposition: form-data; name=\"file\"; filename=\"iphone.jpg\"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[@"Content-Type: application/octet-stream\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[NSData dataWithData:imageData]];
    [body appendData:[@"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
    // close form
    [body appendData:[[NSString stringWithFormat:@"--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
    // set request body
    [request setHTTPBody:body];
    
    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *r, NSData *d, NSError *e) {
        NSLog(@"response: %@", [[NSString alloc] initWithData:d encoding:NSUTF8StringEncoding]);
    }];
    
    <?php 
    //copy file IF a file was uploaded
    
    $imgFile = $_FILES['file']['tmp_name'];
    if(!file_exists($imgFile))
    {
        var_dump($_FILES);
        die("no file uploaded");
    }
    
    print " File: $imgFile\n";
    
    $im = imagecreatefromjpeg($imgFile);
    $imgWidth = imagesx($im);
    $imgHeight = imagesy($im);
    
    
    print " Width: $imgWidth\n";
    print "Height: $imgHeight\n";
    print "Format: red:green:blue\n";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that allows the user to take a picture with the
I have an android application which allows the user to take a picture using
My application allows it's user to start a camera intent to take pictures to
I am developing an application which allow user to take photo and can set
I like to develop a hair styling application for which allows the user to
I'm creating an application (Windows Form) that allows the user to take a screenshot
I have an application that allows a user to add a picture to a
I've been working on a simple application which allows the user to take a
I'm using: Hibernate MySQL jBoss I have to create an application that allows user
I have an application that allows the user to download a csv. This works

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.