V
V
volkkto2021-01-12 14:51:42
Node.js
volkkto, 2021-01-12 14:51:42

Nodejs FabricJs why images are not loading?

const fabric = require("fabric").fabric
const util = require("util");
var canvas = new fabric.StaticCanvas(null, {width:3000,height:3000})

var src ='https://teehunt.top/images/directory/image/original/RG/RGR456E-FRONT.png';
fabric.util.loadImage(src, function(img) {

    var oImg = new fabric.Image(img);
    console.log(oImg)

    oImg.set({
        left: 0,
        top: 0,
        width: 1000,
        height: 1000,
        originX: 'center',
        originY: 'center',
        transparentCorners: false
    });
    canvas.add(oImg);
    canvas.renderAll();

})


saveImg(canvas.toDataURL())
var finish = new Date().getTime()
function saveImg(base64){
    require('child_process').spawn('clip').stdin.end(util.inspect(base64));

}


After running the script, I get an empty canvas at the output . I
try to generate an image without the participation of a browser with text and shapes.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question