title: Compressing / down size / resize image while storing image in iPhone application
body: <p>To understand my question please go through following:</p>
  
  <ul>
  <li>In my application user first taps on a button.</li>
  <li>Image picker controller is displayed</li>
  <li>user selects images / an image from it.</li>
  <li>all that images must be saved to my iPhone application.</li>
  </ul>
  
  <p>I have already implemented this and for doing this I have implemented following code.</p>
  
  <pre><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];
  }
  </code></pre>
  
  <p>But the problem is the user's iPhone may have larger images.</p>
  
  <p>I don't want to store that large images within application.
  for example</p>
  
  <ul>
  <li>user selects an image having size of 1200 x 800 </li>
  <li><p>But I want only 80 x 80 size image</p>
  
  <ol>
  <li>selected images should be down sized to my requirement / 8 mb image to less then 500 kb</li>
  <li>how to store image within resource directory instead of storing in documents directory?</li>
  </ol></li>
  </ul>