From a89beb9c9abf2d1b8c16dcafe7c48dc99e4f31aa Mon Sep 17 00:00:00 2001 From: Nyx0uf Date: Mon, 17 Feb 2014 09:58:15 +0100 Subject: [PATCH] cropToSize: take image orientation into account Fixes #43 --- Categories/UIImage+Resizing.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Categories/UIImage+Resizing.m b/Categories/UIImage+Resizing.m index bf98a72..4ff76b6 100644 --- a/Categories/UIImage+Resizing.m +++ b/Categories/UIImage+Resizing.m @@ -59,6 +59,13 @@ -(UIImage*)cropToSize:(CGSize)newSize usingMode:(NYXCropMode)cropMode break; } + if (self.imageOrientation == UIImageOrientationLeft || self.imageOrientation == UIImageOrientationLeftMirrored || self.imageOrientation == UIImageOrientationRight || self.imageOrientation == UIImageOrientationRightMirrored) + { + CGFloat temp = x; + x = y; + y = temp; + } + CGRect cropRect = CGRectMake(x * self.scale, y * self.scale, newSize.width * self.scale, newSize.height * self.scale); /// Create the cropped image