TimOliver / TOCropViewController

A view controller for iOS that allows users to crop portions of UIImage objects
http://www.timoliver.com.au/2015/06/21/tocropviewcontroller-an-open-source-image-cropper-for-ios/
MIT License
4.73k stars 951 forks source link

2 different shown of crop view?, aspect ratio crop? #133

Closed adinertia closed 8 years ago

adinertia commented 8 years ago

Hello,

Thanks for great library! I have few question.

i'm using in swift the code bellow:

let cropViewController = TOCropViewController(image: image!)
cropViewController.delegate = self
cropViewController.aspectRatioLockEnabled = true
cropViewController.aspectRatioPickerButtonHidden = true
cropViewController.rotateButtonsHidden = true
cropViewController.aspectRatioPreset = .presetSquare
cropViewController.resetAspectRatioEnabled = false
cropViewController.cropView.cropBoxResizeEnabled = false
present(cropViewController, animated: true, completion: nil)
  1. I don't know is this a bug or i'm somethnig missing but when crop present, sometimes it's shown like 2 differents views. Here is picture1 and picture2 but allways must be as picture 2. I've also noticed that when crop view is shown the reset button is already active to revert back is this ok or ?
  2. How crop aspect ratio works ? I've noticed on iphone photos in .presetSquare mode it will crop automaticly to 1000 x 1000 but the problem is with picutre like 720 x 540, the croped aspect ratio will automaticlly go to 270 x 270 why not have as 540x540 if is possible ?

Thanks

TimOliver commented 8 years ago

Oh dear! Can you please post that picture here so I can try it myself?

Also, I did a bunch of layout fixes with the aspect ratio very recently, please make sure you're on the latest version of this library. :)

adinertia commented 8 years ago

Thanks for reply. I update library 4 days ago, i can update it again now if you mybe made some changes in this 4 days.

Here is the picture of 720 x 540 that couse problem with ratio to 270 x 270 (not 540x540 if is possible) and also couses frame view like posted picture 1 above. And also original picture of picture1. Thanks for helping out!

720x540 720-540 and original img_1579

TimOliver commented 8 years ago

Thanks for that! Aha! It was a legit bug. One of the optimisations I'd made to when the crop controller presented on screen had disabled the initial call to re-layout images that had aspect ratios set in advance.

I've fixed it and pushed a new CocoaPods release. Please download it and see if that's working for you now.

As for the image size, when you crop an image, it sets the appropriate Retina display scale on the image so it'll display correctly on your device's screen (270*2 = 540), so it's image.size property is in points, not pixels. The raw pixel size is how you expect it. :)

TimOliver commented 8 years ago

Gonna take a leap of faith here and assume it was fixed. :) Please re-open if otherwise. XD