Closed manyasone closed 2 years ago
@manyasone, well, it's the good question and I knew that someone will ask it sometime.
Currently, the algorithms are pretty straightforward. They operate plain rectangles. Look at the example below.
When the image is not rotated we should solve trivial task (at left).
When the image is rotated on an arbitrary angle the task is much more complicated (at right). When we have two limits simultaneously we should deal with the convex polygon and it's the problem. It's solvable, but it makes things far more complicated.
Most of croppers that supports the described feature don't have the possibility to set the limits for the visible area as this cropper do.
Therefore the short answer is it's impossible right now. The long answer is that it may be possible in the future, but I should pay the price for that, for example, by reducing the cropper's flexibility.
As an alternative probably it's possible to use a custom auto zoom to implement this feature (like react-mobile-cropper
do), but it looks that you will encounter some troubles on this way. That cropper uses the much more modern core.
Allright, thanks! I had already thought of the possibility to use auto zoom on rotate - maybe I'll try it this way.
@manyasone, I forgot to mention the another point.
If the image is not rotated the bounding box for the stencil doesn't depend on its figure:
It gives the possibility to use any possible figure for the stencil (rectangle, rounded rectangle, circle, triangle and etc.). The cropper doesn't need to know about it.
On the other hand, if the image is rotated, the bounding box depends on the stencil figure.
The stencil is an arbitrary component, so the cropper doesn't know what's figure do you use.
Thus, to implement this feature I should sacrifice two things:
It's hard choice, considering that this feature is not implemented in any other alternative web croppers I know (except paid Pintura, that never have two possibilities mentioned above). By the way, if you know any another exceptions (no matter what's framework they use), tell me. It would be helpful.
Hi,
is it possible to limit the boundaries after rotating the image, so that this is not possible anymore:
Instead, the corners of the stencil should always be within the image, so that there can no black area get cropped:
PS: This component seems quite well done!