heitorfr / ios-image-editor

iOS View Controller for image cropping. An alternative to the UIImagePickerController editor with extended features.
MIT License
602 stars 129 forks source link

Get crop rect (from original image) #2

Closed eladleb closed 11 years ago

eladleb commented 11 years ago

Is it possible to add the crop rect (x,y,width,height) of the new cropped image relatively to the original one?

heitorfr commented 11 years ago

Hi eladleb, can you elaborate a bit. I didn't understand exactly what you're trying to do.

eladleb commented 11 years ago

Hi, sure, Say I have a original 400x400 image. I cropped it, and as a result I got a 100x150 uiimage in the completion block.

I would love to know what is the origin point of the 100x150 uiimage, relatively to the original 400x400 image.

If it was the top left, I would expect a 0,0,100,150 CGRect. If it was somewhere in the middle, then a 67,90, 100,150 CGRect would make sense. Screen Shot 2013-01-17 at 10 23 34 AM

heitorfr commented 11 years ago

You have a new property - cropBoundsInSourceImage - that gives you the bounds of the crop rectangle in the image coordinates. Just remember that image coordinates start at the bottom left. And if there was rotation applied, the rect will represent the bounding box of the rotated crop rect. Hope it helps.

eladleb commented 11 years ago

Wow looking great!! works seamlessly. This helps me a lot, thank you very much for taking the time to implement this property.