title: Proper way to resize square cropped images from iPhone's photo library without distortion
body: <p>I would like to upload some square cropped images from the photo library, but somehow the uploaded image's aspect ratio will be corrupted. I don't understand why, because i crop it to 440 x 440, so the ratio should be the same. </p>
  
  <p>I would be very happy if somebody could show me the proper way how can i crop images to square shape, and resize them without any deformations and quality loss. I have to do it only with the images from the device's photo library. </p>
  
  <pre><code>- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
  {
  
      else if (buttonIndex == 1)
      {
          if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary] == YES) {
  
              UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
              imagePicker.sourceType =  UIImagePickerControllerSourceTypePhotoLibrary;
  
              imagePicker.delegate = self;
  
              imagePicker.allowsEditing = YES;
              [self presentViewController:imagePicker animated:YES completion:nil];
              [self.tableView reloadData];
          }
      }
  }
  
  - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
  {
  
      UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
  
      [picker dismissViewControllerAnimated:YES completion:nil];
  
      // resize image
      UIGraphicsBeginImageContext(CGSizeMake(440, 440));
      [image drawInRect: CGRectMake(0, 0, 440, 440)];
      UIImage *smallImage = UIGraphicsGetImageFromCurrentImageContext();
      UIGraphicsEndImageContext();
  
      NSData *imageData = UIImageJPEGRepresentation(smallImage, 1.0);
      [self uploadImage:imageData];
  }
  </code></pre>