1

What Nodejs image processing lib should I use with Heroku to make a dynamic png? I was first trying to make easy SVG file but it seems Facebook sharing does not accept SVG, so I need to generate PNG/GIF.

I was hoping a code like this that would return the image binary stream in http server Response.

//create image
var gd = require('node-gd');
var img = gd.createSync(200, 80);
img.colorAllocate(0, 255, 0);

img.savePng('../test.png', 0, function(error) {
  if (error) throw error;
  img.destroy();
})
Tom
  • 6,725
  • 24
  • 95
  • 159
  • 1
    Sorry, what does this have to do with the HTML `` element? This code makes an image file. That task has nothing to do with canvas. Also, "Response" of what? Are you asking how to generate an image in response to a web request? If so, which server solution? Also, why save the image to a file instead of sending the image data directly with the correct mime type headers? Lots of questions, not enough details... – Mike 'Pomax' Kamermans Jan 22 '20 at 13:18
  • Yes I need to return image stream as http server response – Tom Jan 22 '20 at 13:29
  • I need Heroku compatible solution like this : https://stackoverflow.com/questions/32517602/nodejs-serve-png-generated-by-node-canvas – Tom Jan 22 '20 at 13:31
  • 1
    Okay, so... what's the actual problem? You clearly know how to _make_ an image, so just do that as part of an image request and then write the image data as the response. After setting the correct mime-type header. The code you're showing is just fine, so what's the actual _problem_ you have? – Mike 'Pomax' Kamermans Jan 22 '20 at 13:31

0 Answers0