WDImagePicker
WDImagePicker copied to clipboard
Fix for incorrect crop for some images
There's a bug that got ported from GKImagePicker. I'm not up to speed on the proper use of github so I'll just leave this here. Replace this function in WDImageCropView:
private func calcVisibleRectForResizeableCropArea() -> CGRect {
let resizableView = cropOverlayView as! WDResizableCropOverlayView
// first of all, get the size scale by taking a look at the real image dimensions. Here it
// doesn't matter if you take the width or the height of the image, because it will always
// be scaled in the exact same proportion of the real image
var sizeScale = self.imageView.image!.size.width / self.imageView.frame.size.width
sizeScale *= self.scrollView.zoomScale
// then get the position of the cropping rect inside the image
var visibleRect = resizableView.contentView.convertRect(resizableView.contentView.bounds,
toView: imageView)
visibleRect = WDImageCropView.scaleRect(visibleRect, scale: sizeScale)
return visibleRect
}