Skip to content

Instantly share code, notes, and snippets.

@KennyTw
Last active December 12, 2015 10:47
Show Gist options
  • Save KennyTw/13f369375b4a016fc6d9 to your computer and use it in GitHub Desktop.
Save KennyTw/13f369375b4a016fc6d9 to your computer and use it in GitHub Desktop.
node canvas load image addtext
var img = new Canvas.Image; // Create a new Image
img.src = data;
var canvas = new Canvas(img.width, img.height);
var ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0, img.width, img.height);
ctx.font = '22px Helvetica';
ctx.fillText('Hello World', img.width/2, img.height/3);
var stream = canvas.createPNGStream();*/
res.writeHead(200, {'Content-Type': 'image/jpeg'});
stream.pipe(res);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment