After the bypass image, I do not save the cropped image, but I get data that contains X, Y, Width, height. I use the full image in the fabric, and then I need to set the position of the image with this data in the fabric.
In short: I need to set the coordinates (x, y) of the canvas image. Not a canvas. Only to the image of the canvas. I tried setOriginX, setOriginY, but did not show the result as needed. He gets a position of 0.0. Here is the code
var canvas = new fabric.Canvas('canvas');
var imgElement = document.getElementById('myimg');
var CanImg = new fabric.Image(imgElement, {
setScaleX: img_data.x,
setScaleY: img_data.y
});
$('#canvas').attr('width',img_data.width);
$('#canvas').attr('height',img_data.height);
canvas.setHeight(img_data.height);
canvas.setWidth(img_data.width);
CanImg.selectable = false;
canvas.add(CanImg);
What would be the best thing to do?
source
share