I'm using this in my app:
http://www.html5canvastutorials.com/labs/html5-canvas-drag-and-drop-resize-and-invert-images/
have use anchors for resizing the image ..
What I want is to resize the image and keep its ratio maintained. I don't want it to stretch I'm able to achieve that using this peace of code.:..
if(width) {
image.setSize(width);
}
But this is screwing up the anchors .. Anyone ever tried something like this..
Here it is: JSFIDDLE
JS:
Change lines:
To:
Example
I know is not the question but Ive lost a lot of time trying to solve the problem when the anchors go beyond the image 0 size, which throws a javasacript error:
What I did is adding Math.abs to the image size calcuation formula :
It works fine with both bottom anchors, but not so well with top anchors, I just removed the top anchors which is good enough solution for my project....
Hope this helps someone!
I know this is a horribly old post but I needed to implement this exact thing and found the accepted answer is quite flawed - the left two drag handles move the entire image and act very much unlike an image editing program would, for instance. I am posting my solution in case someone stumbles upon this from a Google search like I did.
Modified KineticJS example in JSBin: http://jsbin.com/iyimuy/1/edit