JsImageCrop icon indicating copy to clipboard operation
JsImageCrop copied to clipboard

How crop ratio can be set for rectangular area ?

Open Olgagr opened this issue 9 years ago • 16 comments

Docs claims this is possible, but I don't see such option.

Olgagr avatar Mar 20 '15 15:03 Olgagr

Right now it crops to the size of your rectangle. You mean you want to specify the aspect ratio?

Can you provide more details?

joncodo avatar Mar 20 '15 15:03 joncodo

Or fix the rectangle to a certain aspect ratio?

joncodo avatar Mar 20 '15 15:03 joncodo

Yes, fix the rectangle to a certain aspect ratio.

Olgagr avatar Mar 20 '15 15:03 Olgagr

It does not do that yet but I could make it do that. When do you need it by?

joncodo avatar Mar 20 '15 16:03 joncodo

As usual, ASAP :)

Olgagr avatar Mar 20 '15 17:03 Olgagr

:) Might be able to get this done by monday.

joncodo avatar Mar 20 '15 17:03 joncodo

:+1:

Olgagr avatar Mar 20 '15 19:03 Olgagr

Feel free to make a pr for this in the meantime. ;)

joncodo avatar Mar 20 '15 19:03 joncodo

I did first step, but there are some issues with my code.

First of all when user sets aspect ratio for rectangular crop area, the starting crop area should be drawn with this aspect ratio.

Second, the min size area should be taken into account.

Last: the accuracy of the calculations. Let's say the ratio is 2. The bottom right corner is moved left by 11px. So the y coordinate should change 11/2 = 5.5. We can't move half pixel. Right now I round it, but of course this causes that we lose accuracy.

Olgagr avatar Mar 21 '15 07:03 Olgagr

Try forcing the scale and only letting the crop area be dragged in one deception.

Use the min width as the lower of the two sides in the aspect ratio?

Sent from my iPhone

On Mar 21, 2015, at 4:45 AM, Olga Grabek [email protected] wrote:

I did first step, but there are some issues with my code.

First of all when user sets aspect ratio for rectangular crop area, the starting crop area should be drawn with this aspect ratio.

Second, the min size area should be taken into account.

Last: the accuracy of the calculations. Let's say the ratio is 2. The bottom right corner is moved left by 11px. So the y coordinate should change 11/2 = 5.5. We can't move half pixel. Right now I round it, but of course this causes that we lose accuracy.

— Reply to this email directly or view it on GitHub.

joncodo avatar Mar 21 '15 11:03 joncodo

Any updates with this?

EDIT: I hacked together an aspect ratio lock for a quick turnaround on a project I'm working on, it's not the most elegant as it simply forces the aspect ratio whenever the rectangular crop area is drawn, but it certainly works if anyone's after a quick fix. Will work on something a little more sensible solution when I'm through this backlog.

lbennett-stacki avatar Mar 27 '15 12:03 lbennett-stacki

Any update on the lock aspect ratio? Or set a defined crop width/height ?

badamadam avatar Jul 28 '15 08:07 badamadam

Please guys update this issue, how to lock aspect ration ?

rdvs avatar Oct 10 '15 20:10 rdvs

That option would be really awesome, i have two project where i could use it :)

CrackerakiUA avatar Oct 11 '15 08:10 CrackerakiUA

Any new developments on this front? This is really a crucial feature. @LukeeeeBennett, would you mind sharing your hack? Either code or an explanation of how you did it would be fine.

davorzdralo avatar Dec 03 '15 13:12 davorzdralo

Actually i build awesome fork, you can check https://github.com/CrackerakiUA/ngImgCropFullExtended

CrackerakiUA avatar Dec 03 '15 17:12 CrackerakiUA