scottcheng / cropit

A "customizable crop and zoom" jQuery plugin.
http://scottcheng.github.io/cropit/
MIT License
875 stars 304 forks source link

Adds rotate feature to a plugin. #44

Closed piotrze closed 9 years ago

piotrze commented 9 years ago

I've added rotate() method to a plugin. For now there is only option to call it from api.

When you rotate image it replace existing image with new dataURL that includes rotated image. After rotation image is simply loaded again.

Rotation algorithm gracefully borrowed from https://github.com/fengyuanchen/cropper plugin.

scottcheng commented 9 years ago

Thanks for the PR!

I definitely like the idea, but there's more subtlety than what's addressed here. One issue is, when the image is rotated, we need an option similar to the current minZoom that determines whether the image has to cover the entire preview area, which in turn affects how much the image may be rotated. I also don't quite like calculating the rotation on a canvas, mainly for performance issues. There is an obvious lag, especially in the case of large images, after each rotation. CSS transform might be a better option.

Good start overall. I'd appreciate it if you'd like to keep working on it, but it's ok otherwise.