-
Notifications
You must be signed in to change notification settings - Fork 176
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
Incorrect crop rect when move and scale squared images #23
Comments
helped me a lot! thanks |
Hmm still having issues on this one.. |
SjoerdPerfors, please ensure that your image is square(width==height), and if that is true, can you send me your image for testing? |
Yeah I realized that too! Why is that? What I do now (I only use the cropperViewController and have my Facebook photopicker first): #import "UIImage+Scaling.h" if(image.size.height > image.size.width) to make it a square and it works. But I'm sure it's not the best solution. |
I guess we are talking on different things. |
Guess you're right! Thanks for your reply. |
In GKImageCropView.m Changed This... To... |
@aerialcombat BIG THANKS !! This helped me a lot ! |
aerialcombat - your post worked for me. I am going to update my "issue" from the board to indicate this is the fix. |
Scale is now sometimes determined for the wrong axis because image scale should be based on image width and height, NOT crop width and height. instead of this from the original function
change it to this and you should be good to go.
|
I had noticed the random wrong axis determination, but had not dug into it. I will put this in. Thanks for looking into it! Scale is now sometimes determined for the wrong axis because image scale should be based on image width and height, NOT crop width and height. instead of this from the original function if (self.cropSize.width > self.cropSize.height) change it to this and you should be good to go. if (self.imageToCrop.size.width > self.imageToCrop.size.height) — |
@aerialcombat thank you :) |
Just a heads up - there are a number of solutions on this thread. The post that solved my problem completely was the original poster's answer (@DvaChisla). The problem that it addressed was that when you selected a completely square image (height == width) from the library, the cropping would be completely off. I have a custom rectangle size as my crop and the final image I got originally was a square image that was completely different. The first posts's solution fixed it for me and now I achieve the result I was after. Cheers. |
Above codes just work for either for Portrait or Landscape. But I needed to support both type of images. So, after several hours of googling I found following solution that works well.
Courtesy: fleshgolem@89447bf |
Sweet. Thanks for this guys! |
Thank you @aerialcombat your answer fix my error. |
GKImagePicker returns incorrectly cropped image for squared images (height == width). And I have found a solution, you need to replace in GKImageCropView.m this code:
" if (self.cropSize.width > self.cropSize.height) {
scale = (self.imageToCrop.size.width < self.imageToCrop.size.height ?
MAX(scaleWidth, scaleHeight) :
MIN(scaleWidth, scaleHeight));
}else{
scale = (self.imageToCrop.size.width < self.imageToCrop.size.height ?
MIN(scaleWidth, scaleHeight) :
MAX(scaleWidth, scaleHeight));
}"
with this one ("<" replaced with "<="):
" if (self.cropSize.width > self.cropSize.height) {
scale = (self.imageToCrop.size.width <= self.imageToCrop.size.height ?
MAX(scaleWidth, scaleHeight) :
MIN(scaleWidth, scaleHeight));
}else{
scale = (self.imageToCrop.size.width <= self.imageToCrop.size.height ?
MIN(scaleWidth, scaleHeight) :
MAX(scaleWidth, scaleHeight));
}"
sorry for my english :)
The text was updated successfully, but these errors were encountered: