y-a-v-a / node-gd

🎨 GD graphics library (libgd) C++ bindings for Node.js.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

support open Src ?

JiaLe1 opened this issue · comments

Hi, I'm trying to open image from Src, what the best way to do that?

Thanks

Hi, @JiaLe1, what do you mean with 'from Src'?

Yeah, I write this code expect open someone image.
like this:

var gd = require('node-gd');
gd.openFile('https://images/xx.png', function(err, img) {
if (err) {
throw err;
}
}

Hi, @JiaLe1
You will first need to retrieve it via the standard http(s)-API of node, then store the image data in a Buffer and pass that to node-gd to do something with it. You could use http.get, as described here: https://nodejs.org/docs/latest-argon/api/http.html#http_http_get_options_callback and use a buffer to store the response asynchronously, then when http fires 'end' event, then pass the Buffer to node-gd to modify / change the image.
Cheers
Vincent

You are a great guys. Thanks for you.

Cheers

thanks!