We can use scalex / scaley to set the height / width, as shown 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
source share