Jonathan Sutherland
Jonathan Sutherland

Reputation: 835

Crop off parts of UIImage for new aspect ratio and scale down to size

I am capturing an image with the UIImagePickerController, and I use the cameraViewTransform to make it full screen on iPhone 5 so there's no black boxes on the top or bottom.

self.imagePicker.cameraViewTransform = CGAffineTransformMakeScale(1.7125, 1.7125);

When the user takes the photo, this returns an image that is 2448 x 3264 pixels. This is a 1.333 ratio, I need to crop off the sides to make it 1906 x 3264 pixels to fit in my view at a new aspect ratio, and then I want to scale it down to 320 x 548 pixels to make it full screen on the iPhone 5 (but not gigantic).

How is this achieved?

Upvotes: 2

Views: 1635

Answers (1)

GoZoner
GoZoner

Reputation: 70135

Use a variation of this. You'll want to add scaling and be cognizant of the order of your operations.

Upvotes: 1

Related Questions