title: Scaling UIImage with a UIIImagePicker's CGAffineTransform and Saving to Parse SDK
body: <p>I use the following code to scale my <code>UIImagePickerController</code>.</p>
  
  <pre><code>    CGAffineTransform translate = CGAffineTransformMakeTranslation(0.0, 71.0); //This slots the preview exactly in the middle of the screen by moving it down 71 points
      self.imagePicker.cameraViewTransform = translate;
      CGAffineTransform scale = CGAffineTransformScale(translate, 1.333333, 1.333333);
      self.imagePicker.cameraViewTransform = scale;
  </code></pre>
  
  <p>Then I take the picture and present it in a <code>UIImageView</code> </p>
  
  <pre><code>- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
  
      [picker dismissViewControllerAnimated:NO completion:NULL];
  
      _imageTaken = nil;
      _imageTaken = [info objectForKey:UIImagePickerControllerEditedImage];
      if(_imageTaken==nil)
      {
          _imageTaken = [info objectForKey:UIImagePickerControllerOriginalImage];
      }
      if(_imageTaken==nil)
      {
          _imageTaken = [info objectForKey:UIImagePickerControllerCropRect];
      }
  
      [_imageTakenView setContentMode:UIViewContentModeScaleAspectFill];
  
      if (_selfie) {
          UIImage * flippedImage = [UIImage imageWithCGImage:_imageTaken.CGImage scale:_imageTaken.scale orientation:UIImageOrientationLeftMirrored];
          _imageTaken = flippedImage;
      }
  
      _imageTakenView.image = _imageTaken;
  }
  </code></pre>
  
  <p>Everything is good so far. Then I send the image up to my database by converting it to <code>NSData</code></p>
  
  <pre><code>    _imageData = [[NSData alloc] init];
      _imageData = UIImageJPEGRepresentation(_image, .1);
  </code></pre>
  
  <p>When I load the data back from the server and present it in another <code>UIImageView</code> of the same size I do set the same aspect ratio: </p>
  
  <pre><code>    [_imageViewToShow setContentMode:UIViewContentModeScaleAspectFill];
  </code></pre>
  
  <p>but the image looks distored (squished horizontally). Any ideas as to why this might be?</p>
  
  <p><strong>Convert UIImage to NSData &amp; Save</strong></p>
  
  <pre><code>_imageData = UIImageJPEGRepresentation(_image, .1);
  PFFile *imageFile = [PFFile fileWithName:@"image.png" data:_imageData];
  newMessage[@"image"] = imageFile;
  </code></pre>
  
  <p><strong>Problem:</strong></p>
  
  <p>When I redownload the data, the UIImage appears squished. When I look at the image on my database, it seems fine. Not sure why this is happening...</p>
  
  <p><strong>Before and After Images:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/dKW5i.jpg" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/KrMzB.png" alt="enter image description here"></p>