How to draw jimp image onto canvas
See original GitHub issueJust wonderting is it possible to draw image modified by jimp on to canvas. When I am trying something like this:
` Jimp.read(“res/table.png”).then(function (image) { // do stuff with the image //image.contrast( val ); // adjust the contrast by a value -1 to +1 console.log(“:read table”); Jimp.loadFont(‘res/fonts/open-sans/open-sans-8-white/open-sans-8-white.fnt’).then(function (font) { console.log(‘font loaded!’ + image); image.print(font, 10, 10, “Hello world!”); /image.write(“table-test.png”, function(error, result){ console.log(error); console.log(result); });/ console.log(image); var canvas = document.createElement(‘canvas’); canvas.width = 150; canvas.height = 180; var ctx = canvas.getContext(‘2d’); ctx.drawImage(image.bitmap,0,0,150,180); // or ctx.drawImage(image,0,0,150,180); });
}).catch(function (err) {
// handle an exception
console.log("can't read image");
});`
I am getting error TypeError: Failed to execute ‘drawImage’ on ‘CanvasRenderingContext2D’: The provided value is not of type ‘(HTMLImageElement or HTMLVideoElement or HTMLCanvasElement or ImageBitmap)’
Issue Analytics
- State:
- Created 7 years ago
- Comments:5
Top GitHub Comments
Sorry already figured it out
I found the following to be the quickest for me: