{"id":2255,"date":"2016-11-11T15:55:56","date_gmt":"2016-11-11T10:25:56","guid":{"rendered":"https:\/\/www.innovationm.com\/blog\/?p=2255"},"modified":"2017-01-24T15:15:37","modified_gmt":"2017-01-24T09:45:37","slug":"image-croprotateresize-handling-in-ios","status":"publish","type":"post","link":"https:\/\/www.innovationm.com\/blog\/image-croprotateresize-handling-in-ios\/","title":{"rendered":"Image Crop \/ Rotate \/ Resize Handling in iOS"},"content":{"rendered":"<p><span style=\"font-weight: 400\">Crop, Rotate and Resize are the fundamental image operations. In app development we come to a situation when we have to do these operations. In this post, I will guide you how to use these operations in your iOS applications using XCode 8.0 and Swift 3.0.<\/span><\/p>\n<h2><span style=\"font-weight: 400\">Image Cropping: <\/span><\/h2>\n<p><span style=\"font-weight: 400\">Image cropping is a process of extracting some interested portion of an image. In this post we will create following method to crop an image:<\/span><span style=\"font-weight: 400\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0<\/span><\/p>\n<pre class=\"lang:swift decode:true\">func crop(image:UIImage, cropRect:CGRect) -&gt; UIImage? {\r\n}<\/pre>\n<p><span style=\"font-weight: 400\">In this method `image` parameter is source image to be cropped and `cropRect` is a rectangle in which image will be cropped. This method will return UIImage object of cropped image.<\/span><\/p>\n<p><span style=\"font-weight: 400\">First we will start from creating an image context for drawing environment<\/span><\/p>\n<pre class=\"lang:swift decode:true\">UIGraphicsBeginImageContextWithOptions(cropRect.size, false, image.scale)<\/pre>\n<p><span style=\"font-weight: 400\">Here we passed the size of resulting image as first parameter, second parameter indicates that the image is not opaque and third parameter specifies the image scale.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Now we will create a point which will translate the source image according to the origin of given cropping rectangle.<\/span><\/p>\n<pre class=\"lang:default decode:true\">let origin = CGPoint(x: cropRect.origin.x * CGFloat(-1), y: cropRect.origin.y * CGFloat(-1))<\/pre>\n<p><span style=\"font-weight: 400\">Now we will draw the source image into current context at the translated point<\/span><\/p>\n<pre class=\"lang:swift decode:true\">image.draw(at: origin)<\/pre>\n<p><span style=\"font-weight: 400\">Now we will get the resulted image, close the image context and return the resulting UIImage object.<\/span><\/p>\n<pre class=\"lang:swift decode:true\">let result = UIGraphicsGetImageFromCurrentImageContext()\r\nUIGraphicsEndImageContext();\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\r\nreturn result<\/pre>\n<p><span style=\"font-weight: 400\">So the final method for image cropping will be:<\/span><\/p>\n<pre class=\"lang:swift decode:true\">func crop(image:UIImage, cropRect:CGRect) -&gt; UIImage? {\r\n    UIGraphicsBeginImageContextWithOptions(cropRect.size, false, image.scale)\r\n    let origin = CGPoint(x: cropRect.origin.x * CGFloat(-1), y: cropRect.origin.y * CGFloat(-1))\r\n\u00a0 \u00a0 image.draw(at: origin)\r\n\u00a0 \u00a0 let result = UIGraphicsGetImageFromCurrentImageContext()\r\n\u00a0 \u00a0 UIGraphicsEndImageContext();\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\r\n    return result\r\n}<\/pre>\n<h2><span style=\"font-weight: 400\">Image Rotation:<\/span><\/h2>\n<p><span style=\"font-weight: 400\">In image rotation we will use transformation matrix to rotate an image. In this example we will do three type of rotations: rotating an image by some degree(<\/span><i><span style=\"font-weight: 400\">\u03b8<\/span><\/i><span style=\"font-weight: 400\">), flip the image vertically and flip the image horizontally. For these rotations we will use 3D rotation matrix.<\/span><\/p>\n<p><span style=\"font-weight: 400\">To rotate an image by some degree(<\/span><i><span style=\"font-weight: 400\">\u03b8<\/span><\/i><span style=\"font-weight: 400\">) we will rotate the image by <\/span><i><span style=\"font-weight: 400\">\u03b8 <\/span><\/i><span style=\"font-weight: 400\">degree<\/span> <span style=\"font-weight: 400\">w.r.t. Z-Axis. For vertical flip we will rotate the the image by 180 degree w.r.t. Y-Axis and for horizontal flip we will rotate the image by 180 degree w.r.t. X-Axis.<\/span><\/p>\n<p><span style=\"font-weight: 400\">The 3D rotation matrix for rotation is following for different axises:<\/span><\/p>\n<p><a href=\"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2016\/11\/3d-Rotation-Matrix.png\"><img decoding=\"async\" class=\"alignleft size-full wp-image-2258\" src=\"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2016\/11\/3d-Rotation-Matrix.png\" alt=\"3d-rotation-matrix\" width=\"202\" height=\"233\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">Now we know that what will be our procedure to rotate and flip an image, So let\u2019s start by defining a method for rotation.<\/span><span style=\"font-weight: 400\">\u00a0 \u00a0 \u00a0 \u00a0<\/span><\/p>\n<pre class=\"lang:swift decode:true\">func rotateImage(image:UIImage, angle:CGFloat, flipVertical:CGFloat, flipHorizontal:CGFloat) -&gt; UIImage? {\r\n}<\/pre>\n<p><span style=\"font-weight: 400\">Here, `image` will be source image to be rotated, `angle` will be the rotation angle in radian, `flipVertical` will indicate whether the image will be flipped vertically or not by setting its value to 1 or 0 and `flipHorizontal` will indicate whether the image will be flipped horizontally or not by setting its value to 1 or 0. This method will return the UIImage object of rotated image.<\/span><\/p>\n<p><span style=\"font-weight: 400\">To convert from degree to radian use following formula:<\/span><\/p>\n<pre class=\"lang:swift decode:true\">angleInRadian = angleInDegree * M_PI \/ 180<\/pre>\n<p><span style=\"font-weight: 400\">Now we will create a CIImage object of given source image and create a Affine Transform filter using CIFilter and set the CIImage object as input to the filter.<\/span><span style=\"font-weight: 400\">\u00a0\u00a0<\/span><\/p>\n<pre class=\"lang:swift decode:true\">let ciImage = CIImage(image: image)\r\n\r\nlet filter = CIFilter(name: \"CIAffineTransform\")\r\nfilter?.setValue(ciImage, forKey: kCIInputImageKey)\r\nfilter?.setDefaults()<\/pre>\n<p><span style=\"font-weight: 400\">By default Affine Transform rotate the image in anti-clockwise direction, so for clockwise rotation we have to multiply the angle by `-1`.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Now we will create a 3D identity transformation matrix.<\/span><span style=\"font-weight: 400\">\u00a0\u00a0<\/span><\/p>\n<pre class=\"lang:swift decode:true\">let newAngle = angle * CGFloat(-1)\r\n\r\nvar transform = CATransform3DIdentity<\/pre>\n<p><span style=\"font-weight: 400\">Apply rotation about Z-Axis by given angle:<\/span><\/p>\n<pre class=\"lang:swift decode:true\">\u00a0transform = CATransform3DRotate(transform, CGFloat(newAngle), 0, 0, 1)<\/pre>\n<p><span style=\"font-weight: 400\">Apply rotation about Y-Axis by <\/span><span style=\"font-weight: 400\"> radian (180 degrees) if flipVertical is 1.<\/span><\/p>\n<pre class=\"lang:swift decode:true\">transform = CATransform3DRotate(transform, CGFloat(Double(flipVertical) * M_PI), 0, 1, 0)<\/pre>\n<p><span style=\"font-weight: 400\">Apply rotation about X-Axis by<\/span> <span style=\"font-weight: 400\"> radian (180 degrees) if flipHorizontal is 1.<\/span><\/p>\n<pre class=\"lang:swift decode:true\">transform = CATransform3DRotate(transform, CGFloat(Double(flipHorizontal) * M_PI), 1, 0, 0)<\/pre>\n<p><span style=\"font-weight: 400\">Now create an Affine transform object from above Transformation matrix and set it to the filter created earlier.<\/span><span style=\"font-weight: 400\">\u00a0 \u00a0\u00a0<\/span><\/p>\n<pre class=\"lang:swift decode:true\">let affineTransform = CATransform3DGetAffineTransform(transform)\r\n\r\nfilter?.setValue(NSValue(cgAffineTransform: affineTransform), forKey: \"inputTransform\")<\/pre>\n<p><span style=\"font-weight: 400\">Now get the rotated image and create a CIContext object for creating new image with extent of rotated image and convert it into UIImage and return.<\/span><span style=\"font-weight: 400\">\u00a0<\/span><\/p>\n<pre class=\"lang:swift decode:true\">let contex = CIContext(options: [kCIContextUseSoftwareRenderer:true])\r\n\r\nlet outputImage = filter?.outputImage\r\nlet cgImage = contex.createCGImage(outputImage!, from: (outputImage?.extent)!)\r\n\r\nlet result = UIImage(cgImage: cgImage!)\r\nreturn result<\/pre>\n<p><span style=\"font-weight: 400\">So the complete method for image rotation and flip will be following:<\/span><\/p>\n<pre class=\"lang:swift decode:true\">func rotateImage(image:UIImage, angle:CGFloat, flipVertical:CGFloat, flipHorizontal:CGFloat) -&gt; UIImage? {\r\n\u00a0 \u00a0let ciImage = CIImage(image: image)\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\r\n\u00a0 \u00a0let filter = CIFilter(name: \"CIAffineTransform\")\r\n\u00a0 \u00a0filter?.setValue(ciImage, forKey: kCIInputImageKey)\r\n\u00a0 \u00a0filter?.setDefaults()\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\r\n\u00a0 \u00a0let newAngle = angle * CGFloat(-1)\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\r\n\u00a0 \u00a0var transform = CATransform3DIdentity\r\n\u00a0 \u00a0transform = CATransform3DRotate(transform, CGFloat(newAngle), 0, 0, 1)\r\n\u00a0 \u00a0transform = CATransform3DRotate(transform, CGFloat(Double(flipVertical) * M_PI), 0, 1, 0)\r\n\u00a0 \u00a0transform = CATransform3DRotate(transform, CGFloat(Double(flipHorizontal) * M_PI), 1, 0, 0)\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\r\n\u00a0 \u00a0let affineTransform = CATransform3DGetAffineTransform(transform)\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\r\n\u00a0 \u00a0filter?.setValue(NSValue(cgAffineTransform: affineTransform), forKey: \"inputTransform\")\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\r\n\u00a0 \u00a0let contex = CIContext(options: [kCIContextUseSoftwareRenderer:true])\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\r\n\u00a0 \u00a0let outputImage = filter?.outputImage\r\n\u00a0 \u00a0let cgImage = contex.createCGImage(outputImage!, from: (outputImage?.extent)!)\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\r\n\u00a0 \u00a0let result = UIImage(cgImage: cgImage!)\r\n\u00a0 \u00a0return result\r\n}<\/pre>\n<h2><span style=\"font-weight: 400\">Image Resizing:<\/span><\/h2>\n<p><span style=\"font-weight: 400\">Resizing is very frequently used operation in mobile applications while uploading an image to application server. Due to high resolution camera available on mobile devices we resize the image before uploading them to our application server.<\/span><\/p>\n<p><span style=\"font-weight: 400\">So let\u2019s define a method for image resizing:<\/span><span style=\"font-weight: 400\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0<\/span><\/p>\n<pre class=\"lang:swift decode:true\">func resizeImage(image:UIImage, targetSize:CGSize) -&gt; UIImage? {\r\n}<\/pre>\n<p><span style=\"font-weight: 400\">Here, `image` is the source image to be resized and `targetSize` is a new size in which source image has to be resized. It returns an object of UIImage.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Calculate the width and height ratio of new image and derive a new size based on the minimum ratio and also make an rectangle using this new size.<\/span><\/p>\n<pre class=\"lang:swift decode:true\">\u00a0let originalSize = image.size\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\r\nlet widthRatio = targetSize.width \/ originalSize.width\r\nlet heightRatio = targetSize.height \/ originalSize.height\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\r\nlet ratio = min(widthRatio, heightRatio)\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\r\nlet newSize = CGSize(width: originalSize.width * ratio, height: originalSize.height * ratio)\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\r\n\/\/ preparing rect for new image size\r\nlet rect = CGRect(x: 0, y: 0, width: newSize.width, height: newSize.height)<\/pre>\n<p><span style=\"font-weight: 400\">Now we will create an image context for drawing environment<\/span><br \/>\n<span style=\"font-weight: 400\">UIGraphicsBeginImageContextWithOptions(newSize, false, UIScreen.main.scale)<\/span><br \/>\n<span style=\"font-weight: 400\">Here we passed the size of resulting image as first parameter, second parameter indicates that the image is not opaque and third parameter specifies the image scale.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Now we will draw the source image into the new rectangle<\/span><\/p>\n<pre class=\"lang:swift decode:true\">image.draw(in: rect)<\/pre>\n<p><span style=\"font-weight: 400\">Now we will get the resulted image, close the image context and return the resulting UIImage object.<\/span><\/p>\n<pre class=\"lang:swift decode:true\">let result = UIGraphicsGetImageFromCurrentImageContext()\r\nUIGraphicsEndImageContext();\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\r\nreturn result<\/pre>\n<p><span style=\"font-weight: 400\">So the final method for Image resizing will be:<\/span><\/p>\n<pre class=\"lang:swift decode:true\">func resizeImage(image:UIImage, targetSize:CGSize) -&gt; UIImage? {\r\n\u00a0 \u00a0 \u00a0let originalSize = image.size\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\r\n\u00a0 \u00a0 \u00a0let widthRatio = targetSize.width \/ originalSize.width\r\n\u00a0 \u00a0 \u00a0let heightRatio = targetSize.height \/ originalSize.height\r\n\r\n\u00a0 \u00a0 \u00a0let ratio = min(widthRatio, heightRatio)\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\r\n\u00a0 \u00a0 \u00a0let newSize = CGSize(width: originalSize.width * ratio, height: originalSize.height * ratio)\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\r\n\u00a0 \u00a0 \u00a0\/\/ preparing rect for new image size\r\n\u00a0 \u00a0 \u00a0let rect = CGRect(x: 0, y: 0, width: newSize.width, height: newSize.height)\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\r\n\u00a0 \u00a0 \u00a0\/\/ Actually do the resizing to the rect using the ImageContext stuff\r\n\u00a0 \u00a0 \u00a0UIGraphicsBeginImageContextWithOptions(newSize, false, UIScreen.main.scale)\r\n\u00a0 \u00a0 \u00a0image.draw(in: rect)\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\r\n\u00a0 \u00a0 \u00a0let newImage = UIGraphicsGetImageFromCurrentImageContext()\r\n\u00a0 \u00a0 \u00a0UIGraphicsEndImageContext()\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\r\n\u00a0 \u00a0 \u00a0return newImage\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Crop, Rotate and Resize are the fundamental image operations. In app development we come to a situation when we have to do these operations. In this post, I will guide you how to use these operations in your iOS applications using XCode 8.0 and Swift 3.0. Image Cropping: Image cropping is a process of extracting [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2256,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,71],"tags":[156],"class_list":["post-2255","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ios","category-mobile","tag-image-handling-in-ios"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Image Crop\/Rotate\/Resize Handling in iOS | InnovationM Blog<\/title>\n<meta name=\"description\" content=\"Crop, Rotate and Resize are the fundamental image operations. In app development we come to a situation when we have to do these operations.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.innovationm.com\/blog\/image-croprotateresize-handling-in-ios\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Image Crop\/Rotate\/Resize Handling in iOS | InnovationM Blog\" \/>\n<meta property=\"og:description\" content=\"Crop, Rotate and Resize are the fundamental image operations. In app development we come to a situation when we have to do these operations.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.innovationm.com\/blog\/image-croprotateresize-handling-in-ios\/\" \/>\n<meta property=\"og:site_name\" content=\"InnovationM - Blog\" \/>\n<meta property=\"article:published_time\" content=\"2016-11-11T10:25:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-01-24T09:45:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2016\/11\/Image-Handling.png\" \/>\n\t<meta property=\"og:image:width\" content=\"914\" \/>\n\t<meta property=\"og:image:height\" content=\"418\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"InnovationM Admin\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"InnovationM Admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/image-croprotateresize-handling-in-ios\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/image-croprotateresize-handling-in-ios\\\/\"},\"author\":{\"name\":\"InnovationM Admin\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#\\\/schema\\\/person\\\/a831bf4602d69d1fa452e3de0c8862ed\"},\"headline\":\"Image Crop \\\/ Rotate \\\/ Resize Handling in iOS\",\"datePublished\":\"2016-11-11T10:25:56+00:00\",\"dateModified\":\"2017-01-24T09:45:37+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/image-croprotateresize-handling-in-ios\\\/\"},\"wordCount\":746,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/image-croprotateresize-handling-in-ios\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/11\\\/Image-Handling.png\",\"keywords\":[\"Image Handling in iOS\"],\"articleSection\":[\"iOS\",\"Mobile\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/image-croprotateresize-handling-in-ios\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/image-croprotateresize-handling-in-ios\\\/\",\"url\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/image-croprotateresize-handling-in-ios\\\/\",\"name\":\"Image Crop\\\/Rotate\\\/Resize Handling in iOS | InnovationM Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/image-croprotateresize-handling-in-ios\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/image-croprotateresize-handling-in-ios\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/11\\\/Image-Handling.png\",\"datePublished\":\"2016-11-11T10:25:56+00:00\",\"dateModified\":\"2017-01-24T09:45:37+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#\\\/schema\\\/person\\\/a831bf4602d69d1fa452e3de0c8862ed\"},\"description\":\"Crop, Rotate and Resize are the fundamental image operations. In app development we come to a situation when we have to do these operations.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/image-croprotateresize-handling-in-ios\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/image-croprotateresize-handling-in-ios\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/image-croprotateresize-handling-in-ios\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/11\\\/Image-Handling.png\",\"contentUrl\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/11\\\/Image-Handling.png\",\"width\":914,\"height\":418},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/image-croprotateresize-handling-in-ios\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Image Crop \\\/ Rotate \\\/ Resize Handling in iOS\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/\",\"name\":\"InnovationM - Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#\\\/schema\\\/person\\\/a831bf4602d69d1fa452e3de0c8862ed\",\"name\":\"InnovationM Admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g\",\"caption\":\"InnovationM Admin\"},\"sameAs\":[\"http:\\\/\\\/www.innovationm.com\\\/\"],\"url\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/author\\\/innovationmadmin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Image Crop\/Rotate\/Resize Handling in iOS | InnovationM Blog","description":"Crop, Rotate and Resize are the fundamental image operations. In app development we come to a situation when we have to do these operations.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.innovationm.com\/blog\/image-croprotateresize-handling-in-ios\/","og_locale":"en_US","og_type":"article","og_title":"Image Crop\/Rotate\/Resize Handling in iOS | InnovationM Blog","og_description":"Crop, Rotate and Resize are the fundamental image operations. In app development we come to a situation when we have to do these operations.","og_url":"https:\/\/www.innovationm.com\/blog\/image-croprotateresize-handling-in-ios\/","og_site_name":"InnovationM - Blog","article_published_time":"2016-11-11T10:25:56+00:00","article_modified_time":"2017-01-24T09:45:37+00:00","og_image":[{"width":914,"height":418,"url":"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2016\/11\/Image-Handling.png","type":"image\/png"}],"author":"InnovationM Admin","twitter_misc":{"Written by":"InnovationM Admin","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.innovationm.com\/blog\/image-croprotateresize-handling-in-ios\/#article","isPartOf":{"@id":"https:\/\/www.innovationm.com\/blog\/image-croprotateresize-handling-in-ios\/"},"author":{"name":"InnovationM Admin","@id":"https:\/\/www.innovationm.com\/blog\/#\/schema\/person\/a831bf4602d69d1fa452e3de0c8862ed"},"headline":"Image Crop \/ Rotate \/ Resize Handling in iOS","datePublished":"2016-11-11T10:25:56+00:00","dateModified":"2017-01-24T09:45:37+00:00","mainEntityOfPage":{"@id":"https:\/\/www.innovationm.com\/blog\/image-croprotateresize-handling-in-ios\/"},"wordCount":746,"commentCount":0,"image":{"@id":"https:\/\/www.innovationm.com\/blog\/image-croprotateresize-handling-in-ios\/#primaryimage"},"thumbnailUrl":"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2016\/11\/Image-Handling.png","keywords":["Image Handling in iOS"],"articleSection":["iOS","Mobile"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.innovationm.com\/blog\/image-croprotateresize-handling-in-ios\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.innovationm.com\/blog\/image-croprotateresize-handling-in-ios\/","url":"https:\/\/www.innovationm.com\/blog\/image-croprotateresize-handling-in-ios\/","name":"Image Crop\/Rotate\/Resize Handling in iOS | InnovationM Blog","isPartOf":{"@id":"https:\/\/www.innovationm.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.innovationm.com\/blog\/image-croprotateresize-handling-in-ios\/#primaryimage"},"image":{"@id":"https:\/\/www.innovationm.com\/blog\/image-croprotateresize-handling-in-ios\/#primaryimage"},"thumbnailUrl":"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2016\/11\/Image-Handling.png","datePublished":"2016-11-11T10:25:56+00:00","dateModified":"2017-01-24T09:45:37+00:00","author":{"@id":"https:\/\/www.innovationm.com\/blog\/#\/schema\/person\/a831bf4602d69d1fa452e3de0c8862ed"},"description":"Crop, Rotate and Resize are the fundamental image operations. In app development we come to a situation when we have to do these operations.","breadcrumb":{"@id":"https:\/\/www.innovationm.com\/blog\/image-croprotateresize-handling-in-ios\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.innovationm.com\/blog\/image-croprotateresize-handling-in-ios\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.innovationm.com\/blog\/image-croprotateresize-handling-in-ios\/#primaryimage","url":"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2016\/11\/Image-Handling.png","contentUrl":"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2016\/11\/Image-Handling.png","width":914,"height":418},{"@type":"BreadcrumbList","@id":"https:\/\/www.innovationm.com\/blog\/image-croprotateresize-handling-in-ios\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.innovationm.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Image Crop \/ Rotate \/ Resize Handling in iOS"}]},{"@type":"WebSite","@id":"https:\/\/www.innovationm.com\/blog\/#website","url":"https:\/\/www.innovationm.com\/blog\/","name":"InnovationM - Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.innovationm.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.innovationm.com\/blog\/#\/schema\/person\/a831bf4602d69d1fa452e3de0c8862ed","name":"InnovationM Admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g","caption":"InnovationM Admin"},"sameAs":["http:\/\/www.innovationm.com\/"],"url":"https:\/\/www.innovationm.com\/blog\/author\/innovationmadmin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/posts\/2255","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/comments?post=2255"}],"version-history":[{"count":0,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/posts\/2255\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/media\/2256"}],"wp:attachment":[{"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/media?parent=2255"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/categories?post=2255"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/tags?post=2255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}