     
     func setImageRotation(angle: CGFloat) {
         
-        updateMasks()
-        
-        // rotate scroll view
         self.angle = angle
         
-        // position scroll view
-        let width = fabs(cos(self.angle)) * self.cropView.frame.size.width + fabs(sin(self.angle)) * self.cropView.frame.size.height
-        let height = fabs(sin(self.angle)) * self.cropView.frame.size.width + fabs(cos(self.angle)) * self.cropView.frame.size.height
-        let center = self.scrollView.center
-        
-        let contentOffset = self.scrollView.contentOffset
-        let contentOffsetCenter = CGPointMake(contentOffset.x + self.scrollView.bounds.size.width / 2, contentOffset.y + self.scrollView.bounds.size.height / 2)
-        let newBounds = CGRectMake(0, 0, width, height)
-        let newContentOffset = CGPointMake(contentOffsetCenter.x - newBounds.size.width / 2, contentOffsetCenter.y - newBounds.size.height / 2)
-        
-        self.scrollView.transform = CGAffineTransformMakeRotation(angle)
-        self.scrollView.bounds = newBounds
-        self.scrollView.center = center
-        self.scrollView.contentOffset = newContentOffset
+        let width = fabs(cos(angle)) * cropSize.width + fabs(sin(angle)) * cropSize.height
+        let height = fabs(sin(angle)) * cropSize.width + fabs(cos(angle)) * cropSize.height
+        let center = scrollView.center
+        
+        let contentOffsetCenter = CGPoint(
+            x: scrollView.contentOffset.x + scrollView.bounds.size.width / 2,
+            y: scrollView.contentOffset.y + scrollView.bounds.size.height / 2
+        )
+        
+        let newBounds = CGRect(x: 0, y: 0, width: width, height: height)
+        let newContentOffset = CGPoint(
+            x: contentOffsetCenter.x - newBounds.size.width / 2,
+            y: contentOffsetCenter.y - newBounds.size.height / 2
+        )
+        
+        scrollView.transform = CGAffineTransformMakeRotation(angle)
+        scrollView.bounds = newBounds
+        scrollView.center = center
+        scrollView.contentOffset = newContentOffset
         
         // scale scroll view
-        let shouldScale = self.scrollView.contentSize.width / self.scrollView.bounds.size.width <= 1.0 || self.scrollView.contentSize.height / self.scrollView.bounds.size.height <= 1.0
-        
-        if !self.manualZoomed || shouldScale {
-            self.scrollView.setZoomScale(self.scrollView.zoomScaleToBound(), animated: false)
-            self.scrollView.minimumZoomScale = self.scrollView.zoomScaleToBound()
+        let shouldScale = scrollView.contentSize.width / scrollView.bounds.size.width <= 1.0 || self.scrollView.contentSize.height / self.scrollView.bounds.size.height <= 1.0
+        
+        if !manualZoomed || shouldScale {
             
-            self.manualZoomed = false
+            let zoomScale = scrollView.zoomScaleToBound()
+            
+            scrollView.setZoomScale(zoomScale, animated: false)
+            scrollView.minimumZoomScale = zoomScale
+            
+            manualZoomed = false
         }
         
         checkScrollViewContentOffset()

    func photoTranslation() -> CGPoint {
        let rect = scrollView.imageView.convertRect(scrollView.imageView.bounds, toView: self)
        let point = CGPoint(x: rect.origin.x + rect.size.width / 2, y: rect.origin.y + rect.size.height / 2)
        let zeroPoint = CGPoint(x: self.frame.size.width / 2, y: _centerY)
        return CGPoint(x: point.x - zeroPoint.x, y: point.y - zeroPoint.y)
    }
    

        setImageRotation(0)
        
        // scale the image
        cropSize = CGSize(
            width: bounds.size.width,
            height: bounds.size.width / cropAspectRatio
        )
        
        let scaleX = image.size.width / cropSize.width
        let scaleY = image.size.height / cropSize.height
        let scale = min(scaleX, scaleY)     // get minimum scale to fill canvas with image
        
        let minZoomBounds = CGRect(
            x: 0,
            y: 0,
            width: image.size.width / scale,
            height: image.size.height / scale
        )
        
        originalSize = minZoomBounds.size
        
        scrollView.bounds = minZoomBounds
        scrollView.center = self.center
        scrollView.contentSize = scrollView.bounds.size
        
        scrollView.imageView.frame = scrollView.bounds
        
        originalPoint = convertPoint(scrollView.center, toView: self)
        
        updateMasks()
        
