How to upload an image to a canvas with Fabric.js?

后端 未结 3 511
轮回少年
轮回少年 2020-12-28 08:31

I want that to create a process where the users can upload their images and then edit them in the browser in a Canvas with Fabric.js using some buttons, which uses Fabric.js

3条回答
  •  一生所求
    2020-12-28 08:58

     var canvas = new fabric.Canvas('main-canvas');
            canvas.selection = false;
            var imgElement = document.getElementById("img11");
    
            var imgInstance = new fabric.Image(imgElement, {
                angle: 0,
                position: 'absolute',
                opacity: 1,
                originX: 'left',
                originY:'top',
                meetOrSlice:'slice',
    
            });
            imgInstance.selectable = false;
            canvas.add(imgInstance);
            canvas.renderAll();
    

提交回复
热议问题