I had loaded image in canvas using fabric.Image.fromURL and working fine with default image width and height. Now I want to minimize width and height of an image. How to do this?
Thanks in advance.
We can use scalex / scaley to set height / width as below.
fabric.util.loadImage(imgsrc, function (img) {
    var legimg = new fabric.Image(img, {
        left: 30,
        top: marker.top,
        scaleX: 20 / img.width,
        scaleY: 20 / img.height
    });
    canvas.add(legimg);
    canvas.renderAll();
});
Thanks
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With