Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong image size after pressing "Done" button without any changes, or after restoring to default image. #373

Open
alexey-serdykov opened this issue Sep 17, 2019 · 2 comments
Assignees
Labels

Comments

@alexey-serdykov
Copy link

Hi, I'm using your framework in my app, it's cool, but I found some small issues: I present cropViewController with image with size (width: 1200.0, height: 1600.0) then press "Done" button without any changes(or crop and restore without dismissing the controller) and I get image with size (width: 1200.0, height: 1599.0) in the didCropToImage method. The same size is in the cropRect.

@IlyaMakarevich
Copy link

Hello! Do you have any ideas about this bug?

@alexey-serdykov
Copy link
Author

Just duplicating my answer here.

I didn't try to fix this bug exactly in the pod(I looked up and there's problem with rounding in the calculations), but I found out how to deal with this bug. In my case, I just needed to know whether the image was cropped or not, and if it was cropped to take the crop data. So, I do a little trick, in the

func cropViewController(_ cropViewController: CropViewController, didCropImageToRect rect: CGRect, angle: Int)

or in the

func cropViewController(_ cropViewController: CropViewController, didCropToImage image: UIImage, withRect cropRect: CGRect, angle: Int)

delagate methods and I check the reset button's state there. If the button is enabled, then the image was cropped.

func cropViewController(_ cropViewController: CropViewController, didCropImageToRect rect: CGRect, angle: Int) {
    let isImageCropped = cropViewController.toolbar.resetButton.isEnabled

    if isImageCropped {
        // The image is cropped, we can use the returned data.
    } else {
        // The image is not cropped.
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants