0

我和 jimp 一起工作。我正在尝试在现有图像上创建文本。但情况没有改变。

let Jimp = require('jimp')

var _this = this;
 
  
Jimp.read("assets/TimeLine.png").then(function (image) {
  
  Jimp.loadFont("assets/1.fnt").then(font => {
    image.print(font,10, 10,'Hello world that wraps!', 12);
  });

  image.getBase64(Jimp.MIME_JPEG, function (err, src) {
    var img = document.createElement("img");
    img.setAttribute("src", src);   
                  
    _this.timelineStrings = src.toString();    
  });
  
  }).catch(function (err) {
    console.error("! "+ err);
  });
  
}

4

1 回答 1

1

我发现了我的错误。对不起

let Jimp = require('jimp')

var _this = this;
 
  
Jimp.read("assets/TimeLine.png").then(function (image) {
  
  Jimp.loadFont("assets/1.fnt").then(font => {
    image.print(font,10, 10,'Hello world that wraps!', 12)
      .getBase64(Jimp.MIME_JPEG, function (err, src) {
        var img = document.createElement("img");
        img.setAttribute("src", src);   
                  
        _this.timelineStrings = src.toString();    
    });
  });

  
  
  }).catch(function (err) {
    console.error("! "+ err);
  });
  
}

于 2020-01-11T12:08:08.497 回答