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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:41:10+00:00 2026-05-26T15:41:10+00:00

I am using UIImagePickerController for bring images from the photo library, i found this

  • 0

I am using UIImagePickerController for bring images from the photo library,

i found this method for saving the uiimage as png or jpeg:

- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];

    // Create paths to output images
    NSString  *pngPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Test.png"];
    NSString  *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Test.jpg"];

    // Write a UIImage to JPEG with minimum compression (best quality)
    // The value 'image' must be a UIImage object
    // The value '1.0' represents image compression quality as value from 0.0 to 1.0
    [UIImageJPEGRepresentation(image, 1.0) writeToFile:jpgPath atomically:YES];

    // Write image to PNG
    [UIImagePNGRepresentation(<#UIImage *image#>) writeToFile:jpgPath atomically:YES];

    // Let's check to see if files were successfully written...

    // Create file manager
    NSError *error;
    NSFileManager *fileMgr = [NSFileManager defaultManager];

    // Point to Document directory
    NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];

    // Write out the contents of home directory to console
    NSLog(@"Documents directory: %@", [fileMgr contentsOfDirectoryAtPath:documentsDirectory error:&error]);

    [picker release];
}

the problem is that the file in png is 6.4 mb and in jpeg 3.2 mb, there is a way for saving the image file in smaller size then this?

  • 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-26T15:41:11+00:00Added an answer on May 26, 2026 at 3:41 pm

    you could resize image and save image in smaller size.

    Here is an example of method for resizing image:

    - (void)setThumbnailFromImage:(UIImage *)image {
        CGSize origImageSize = [image size];
    
        CGRect newRect;
        newRect.origin = CGPointZero;
        newRect.size = CGSizeMake(40, 40);
    
        // how do we scale the image?
        float ratio = MAX(newRect.size.width/origImageSize.width,
                          newRect.size.height/origImageSize.height);
    
        // create a bitmap image context
        UIGraphicsBeginImageContext(newRect.size);
    
        // Round the corners
        UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:newRect
                                                        cornerRadius:5.0];
        [path addClip];
    
        // into what rectangle shall I composite the image?
        CGRect projectRect;
        projectRect.size.width = ratio * origImageSize.width;
        projectRect.size.height = ratio * origImageSize.height;
        projectRect.origin.x = (newRect.size.width - projectRect.size.width) / 2.0;
        projectRect.origin.y = (newRect.size.height - projectRect.size.height) / 2.0;
    
        // draw the image on it
        [image drawInRect:projectRect];
    
        // get the image from the image context, retain it as our thumbnail
        UIImage *small = UIGraphicsGetImageFromCurrentImageContext();
        [self setThumbnail:small];
    
        // cleanup image contex resources, we're done
        UIGraphicsEndImageContext();
    }
    

    Hope this will help you! =)

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

Sidebar

Related Questions

I am using UIImagePickerController to load saved photo from iphone library. but when I
I am using UIImagePickerController to take a photo from the camera. However, the I
I am using UIImagePickerController to choose video file from library. And user can upload
In my game I'm grabbing an image from the iPhone's photo library using the
I have found a lot of information on using UIImagePickerController to let the user
I am taking pictures from the iPhone camera using the UIImagePickerController Class. I am
I am using UIImagePickerController for get photos from the device and I want to
I'm using UIImagePickerController to let my user take a photo or choose a photo
I'm using UIImagePickerController class to capture image from camera. When is captured, I save
I'm using the UIImagePickerController to take a photo and then upload the photo 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.