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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:53:20+00:00 2026-05-12T14:53:20+00:00

To understand my question please go through following: In my application user first taps

  • 0

To understand my question please go through following:

  • In my application user first taps on a button.
  • Image picker controller is displayed
  • user selects images / an image from it.
  • all that images must be saved to my iPhone application.

I have already implemented this and for doing this I have implemented following code.

 -(IBAction)setPhoto:(id)sender {
    facPhotoPicker=[[UIImagePickerController alloc]init];
    facPhotoPicker.delegate=self;
    facPhotoPicker.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
    facPhotoPicker.allowsImageEditing=YES;
    facPhotoPicker.navigationBar.barStyle=UIBarStyleBlackOpaque;
    [self presentModalViewController:facPhotoPicker animated:YES];
}

-(void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info {
    NSData *imgData=UIImageJPEGRepresentation([info objectForKey:@"UIImagePickerControllerOriginalImage"],1);
    UIImage *img=[[UIImage alloc] initWithData:imgData];
    facImgView.image=img;
    [img release];
    NSString *str=[NSString stringWithFormat:@"%i.jpg",[currentFaculty facultyNo]];
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *path = [NSString stringWithFormat:@"%@/%@", [paths objectAtIndex:0], str];
    [imgData writeToFile:path atomically:YES];
    [picker dismissModalViewControllerAnimated:YES];
}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
    [picker dismissModalViewControllerAnimated:YES];
}

But the problem is the user’s iPhone may have larger images.

I don’t want to store that large images within application.
for example

  • user selects an image having size of 1200 x 800
  • But I want only 80 x 80 size image

    1. selected images should be down sized to my requirement / 8 mb image to less then 500 kb
    2. how to store image within resource directory instead of storing in documents directory?
  • 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-12T14:53:20+00:00Added an answer on May 12, 2026 at 2:53 pm

    This is solved.

    The main key for downsizing. I downsized an image up to 116 kb.


    NSData *imgData=UIImageJPEGRepresentation([info objectForKey:@"UIImagePickerControllerOriginalImage"],compressionRatio);
    while ([imgData length]>50000) { 
        compressionRatio=compressionRatio*0.5;
        imgData=UIImageJPEGRepresentation([info objectForKey:@"UIImagePickerControllerOriginalImage"],compressionRatio);
    }
    

    -(void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info
    {
    double compressionRatio=1;
    NSData *imgData=UIImageJPEGRepresentation([info objectForKey:@"UIImagePickerControllerOriginalImage"],compressionRatio);
    while ([imgData length]>50000) { 
        compressionRatio=compressionRatio*0.5;
        imgData=UIImageJPEGRepresentation([info objectForKey:@"UIImagePickerControllerOriginalImage"],compressionRatio);
    }
    UIImage *img=[[UIImage alloc] initWithData:imgData];
    facImgView.image=img;
    NSLog(@"%@",[info objectForKey:@"UIImagePickerControllerOriginalImage"],3);
    [img release];
    
    
    NSString *str=[NSString stringWithFormat:@"%i.jpg",[currentFaculty facultyNo]];
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *path = [NSString stringWithFormat:@"%@", [paths objectAtIndex:0]];
    path=[path stringByDeletingLastPathComponent];
    path=[NSString stringWithFormat:@"%@/%@",path,str];
    [imgData writeToFile:path atomically:YES];
    [picker dismissModalViewControllerAnimated:YES];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Forgive my probably incorrect application of terminology in this question (btw, please correct me
While I understand this question is fairly vague since I'm not giving you all
I understand that the question is rather hard to understand, I didn't know how
The question is simple: I cannot understand the Zipper data structure. My question is
This question is for the java language in particular. I understand that there is
This is just a question to help me understand CSS rendering better. Lets say
There was an interesting question in a practice test that I did not understand
This is a follow up question to This Question . I like (and understand)
Does my question make sense? Using either Vim or Emacs, you come to understand
This is a somewhat bizarre question. My objectives are to understand the language design

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.