Giter Club home page Giter Club logo

node-gd's Introduction

node-gd logo

node-gd

GD graphics library, libgd, C++ bindings for Node.js. This version is the community-maintained official NodeJS node-gd repo. With node-gd you can easily create, manipulate, open and save paletted and true color images from and to a variety of image formats including JPEG, PNG, GIF and BMP.

Installation

Preconditions

Have environment-specific build tools available. Next to that: to take full advantage of node-gd, best is to ensure you install the latest version of libgd2, which can be found at the libgd github repository.

On Debian/Ubuntu

$ sudo apt-get install libgd-dev # libgd
$ npm install node-gd

On RHEL/CentOS

$ sudo yum install gd-devel
$ npm install node-gd

On Mac OS/X

Using Homebrew

$ brew install pkg-config gd
$ npm install node-gd

...or using MacPorts

$ sudo port install pkgconfig gd2
$ npm install node-gd

Will not build on Windows!

Sorry, will not build on Windows. I have no Windows machine to make it work. It could work, but I just don't have the stuff at hand.

Usage

There are different flavours of images, of which the main ones are palette-based (up to 256 colors) and true color images (millions of colors). GIFs are always palette-based, PNGs can be both palette-based or true color. JPEGs are always true color images. gd.create() will create a palette-based base image while gd.createTrueColor() will create a true color image.

API

Full API documentation and more examples can be found in the docs directory or at the dedicated github page.

Examples

Example of creating a rectangular image with a bright green background and in magenta the text "Hello world!"

// Import library
import gd from 'node-gd';

// Create blank new image in memory
const img = await gd.create(200, 80);

// Set background color
img.colorAllocate(0, 255, 0);

// Set text color
const txtColor = img.colorAllocate(255, 0, 255);

// Set full path to font file
const fontPath = '/full/path/to/font.ttf';

// Render string in image
img.stringFT(txtColor, fontPath, 24, 0, 10, 60, 'Hello world!');

// Write image buffer to disk
await img.savePng('output.png', 1);

// Destroy image to clean memory
img.destroy();

Example of drawing a red lined hexagon on a black background:

import gd from 'node-gd';

const img = await gd.createTrueColor(200, 200);

const points = [
  { x: 100, y: 20 },
  { x: 170, y: 60 },
  { x: 170, y: 140 },
  { x: 100, y: 180 },
  { x: 30, y: 140 },
  { x: 30, y: 60 },
  { x: 100, y: 20 },
];

img.setThickness(4);
img.polygon(points, 0xff0000);
await img.saveBmp('test1.bmp', 0);
img.destroy();

Another example:

import gd from 'node-gd';

const img = await gd.openFile('/path/to/file.jpg');

img.emboss();
img.brightness(75);
await img.file('/path/to/newFile.bmp');
img.destroy();

Some output functions are synchronous because they are handled by libgd. An example of this is the creation of animated GIFs.

License & copyright

Since December 27th 2012, node-gd is licensed under an MIT license.

The MIT License (MIT) Copyright (c) 2010-2020 the contributors.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Contributors

The current version is based on code created by taggon, here the original author's repo, and on the additions by mikesmullin. Porting node-gd to node-addon-api and extending the API is done by y-a-v-a, on Twitter as @_y_a_v_a_. See the CONTRIBUTORS.md file for a list of all contributors.

node-gd's People

Contributors

andris9 avatar blakmatrix avatar buraktamturk avatar cclauss avatar danyshaanan avatar dependabot[bot] avatar gabrieledarrigo avatar holixus avatar kmpm avatar mikesmullin avatar sheershoff avatar tdebarochez avatar tim-smart avatar topaxi avatar vitorbertolucci avatar vladislav805 avatar y-a-v-a avatar zaro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

node-gd's Issues

Error: Argument 2 must be a function

I'm using Mac OS X Yosemite, trying to test the example:

// Require library
var gd = require('node-gd');

// Create blank new image in memory
var img = gd.create(200, 80);

// Set background color
img.colorAllocate(0, 255, 0);

// Set text color
var txtColor = img.colorAllocate(255, 0, 255);

// Set full path to font file
var fontPath = '/full/path/to/font.ttf';

// Render string in image
img.stringFT(txtColor, fontPath, 24, 0, 10, 60, 'Hello world!');

// Write image buffer to disk
img.savePng('output.png', 1, function(err) {
if(err) {
throw err;
}
});

And I getting this error:

/Users/jpacora/Documents/node/kdash/index.js:5
var img = gd.createTrueColor(200, 80);
^
Error: Argument 2 must be a function
at Error (native)
at Object. (/Users/jpacora/Documents/node/kdash/index.js:5:14)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3

Error on Ubuntu 12.04

When installing libgd2-xpm-dev on Ubuntu 12.04, it installs package libgd2 at version libgd2-2.0.36rc1dfsg which appears not to contain gdImageEllipse, while the header file gd.h actually contains two declarations of gdImageEllipse.

Cannot find module ......./build/default/node_gd.node'

Hola,

just updated to stable node v4.2.1 (on El Capitan) and getting an error when installing the package:
screen shot 2015-10-23 at 10 11 45 pm

and then when i try to run the example (shown on tonic):

screen shot 2015-10-23 at 10 09 02 pm

i blew away my local node_modules dir and reinstalled, but i keep getting the same thing. I think this is a cascading problem - any suggestions? thanks!!

module.js:339
    throw err;
    ^

Error: Cannot find module '/Users/neal/Sites/escobar/node_modules/node-gd/js/../build/default/node_gd.node'
    at Function.Module._resolveFilename (module.js:337:15)
    at Function.Module._load (module.js:287:25)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/Users/neal/Sites/escobar/node_modules/node-gd/js/node-gd.js:139:16)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)

node-gd equivalent of PHP imagecolorsforindex

I'm enjoying this library so far and have found it very useful to my project.
But I'm at a stage where this library is lacking the only function I need to finish it up.

I have a set of images that are white and some that are statically colored which are not supposed to be recolored. The sets contain from 1-5 images, and some of them can be color-able by the user.
Currently when I try to recolor an image by it's width and height I get something like this:
https://i.imgur.com/s4C60BX.png

But in the PHP equivalent when using imagecolorsforindex and imagecolorat and setting the pixel this doesn't happen.

$width = imagesx($image);
	$height = imagesy($image);

	for($x = 0; $x < $width; $x++)
	{
		for($y = 0; $y < $height; $y++)
		{
			$rgb = imagecolorsforindex($image, imagecolorat($image, $x, $y));
			$r = $rgb['red'];
			$g = $rgb['green'];
			$b = $rgb['blue'];
			$a = $rgb['alpha'];

			$r = (($red / 255) * $r);
			$g = (($green / 255) * $g);
			$b = (($blue / 255) * $b);

			imagesetpixel($image, $x, $y, imagecolorallocatealpha($image, $r, $g, $b, $a));
		}
	}

At the moment all I've figured out how to do is this:

for (let x = 0; x < image.width; x++) {
			for (let y = 0; y < image.height; y++) {
				// @TODO: Find equivalent node-gd fn of PHP imagecolorsforindex

				image.setPixel(x, y, image.colorAllocate(r, g, b))
			}
		}

This is probably a feature request, but I'll post it here for now.

img.filledArc() expected 8 arguments, only 7 listed in the docs

So, I can use img.arc() fine, but if I change it to img.filledArc() with the same parameters, it hangs the app. Nothing is returned and code execution stops there.

If I try to catch the error, I get [Error: Expected 8 arguments]. The documentation states only 7 arguments. Looking at http://php.net/manual/en/function.imagefilledarc.php it seems the last argument is the fill style. It will be good to get it into the api docs.

node v4.4.3
[email protected]

Failing to build on GD library 2.1.1 with TIFF disabled

I can not npm install node-gd. Here are some infomations:

module.js:356
  Module._extensions[extension](this, filename);
                               ^
Error: /opt/lampp/htdocs/expressjs/stebeneva.ru/node_modules/node-gd/build/Release/node_gd.node: undefined symbol: gdImageTiffPtr
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/opt/lampp/htdocs/expressjs/stebeneva.ru/node_modules/node-gd/js/node-gd.js:44:17)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/opt/lampp/htdocs/expressjs/stebeneva.ru/app.js:14:31)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)

From error log, I assumed this is because I can not build some tiff function which is gdImageTiffPtr. I have no idea how to enable TIFF features from GD library directly. I use Ubuntu 12.04, and the ones from Ubuntu repository is version 2.0. So I build with following instruction from https://github.com/libgd/libgd/tree/master/docs but I can not figure out how to enable TIFF support.

Here is my GD config

āÆ gdlib-config --all     
GD library  2.1.1
includedir: /usr/local/include
cflags:     -I/usr/local/include
ldflags:    
libs:       -ljpeg -lz -lm  -lpng12   -lfreetype   -lfontconfig   -lfontconfig -lXpm -lX11   
libdir:     /usr/local/lib
features:   GD_XPM GD_JPEG GD_FONTCONFIG GD_FREETYPE GD_PNG GD_GIF GD_GIFANIM GD_OPENPOLYGON

On node-gd readme, it mentioned that this module should still support old GD version, with main differences in function availability. I hope some TIFF function will not break module build.

Thank you. šŸŗ šŸ‘

Prepare for github pages

  • Change branch name from stable to master
  • Set master as default branch
  • Change repository configuration to prepare for github pages.

Implement Nan v2.0.0

Got it to work on branch nan2, but would be nice to implement the AsyncWorker for the gd.Image#fileCallback function.

Creating a PNG from RGBA array

Hi,

Is it possible to load a buffer of rgba values with one command? Right now I do gd.createTrueColor and then image.setPixel(x, y, gd.trueColorAlpha(r, g, b, a)); for every pixel.

Thanks

Sending image to client results in image that cannot be displayed

I'm using express and trying to send the created image to the client (preferably without saving to disk).

//create image
var gd = require('node-gd');
var img = gd.createSync(200, 80);
img.colorAllocate(0, 255, 255);
        
var imageData = img.pngPtr();
res.set('Content-Type', 'image/png');
res.send(imageData);

When trying to load the page I get "The image cannot be displayed because it contains errors."

checking the prototype of gd.Image is fatal

var gd = require('node-gd');
var img = gd.create(100,100);
console.log(img.__proto__);

This throws an exception from Node and kills the process. This has to do with the accessors.

t->PrototypeTemplate()->SetAccessor(...);

Since the accessors of width, height, trueColor, interlace and colorsTotal are instance specific, they should be changed into:

t->InstanceTemplate()->SetAccessor(...);

How can I imagecreatefromjpeg()?

Hi I came from a PHP background and came across your module. It looks like this is the one I am looking for, but do you know how can I imagecreatefromjpeg($template) using this module?

Thanks in Advance!

Base64 encode png buffer

I'd like to:

  • Open a png image
  • Merge this png with an overlay png
  • Encode the merged result buffer as a base64 string

My test code:

gd.openPng('./my_image.png', function(err, img) {
    img.saveAlpha(1);
    gd.openPng('./my_overlay.png', function(err, overlay) {
	overlay.copy(img, 0, 0, 0, 0, overlay.width, overlay.height);

	let buff = gd.createFromPngPtr(new Buffer(img.pngPtr())); /* this returns null? */
        console.log(buff); /* prints null as per previous line */

        let b64 = buff.toString('base64'); /* error: Cannot read property 'toString' of null */
        console.log(b64);        
    });
});

Why am I getting a null return on the gd.createFromPngPtr call?

Playing around with the examples in the documentation, the following snippet core dumps:

gd.openPng('./my_image.png', function(err, img) {
    let x = img.pngPtr(9);
    let y = gd.createFromPngPtr(x); // core dump
});

With node v6:
$ nvm list
-> v6.11.0

../src/string_bytes.cc:273:static size_t node::StringBytes::Write(v8::Isolate*, char*, size_t, v8::Localv8::Value, node::encoding, int*): Assertion `val->IsString() == true' failed.

With node v8:
$ nvm list
v6.11.0
-> v8.1.0

../src/string_bytes.cc:273:static size_t node::StringBytes::Write(v8::Isolate*, char*, size_t, v8::Localv8::Value, node::encoding, int*): Assertion `val->IsString() == true' failed.

During both runs, I'm using native libgd-dev v 2.2.101ubuntu3.3:
$ apt search libgd-dev
Sorting... Done
Full Text Search... Done
libgd-dev/yakkety-updates,yakkety-security,now 2.2.1-1ubuntu3.3 amd64 [installed]
GD Graphics Library (development version)

Fails installing in CentOS

I'm receiving this error all the time.

> [email protected] install /home/user/workspace/dashboard/node_modules/node-gd
> node-gyp rebuild

make: Entering directory `/home/user/workspace/dashboard/node_modules/node-gd/build'
  CXX(target) Release/obj.target/node_gd/cpp/addon.o
make: g++: Command not found
make: *** [Release/obj.target/node_gd/cpp/addon.o] Error 127
make: Leaving directory `/home/user/workspace/dashboard/node_modules/node-gd/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 3.10.0-042stab111.12
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/user/workspace/dashboard/node_modules/node-gd
gyp ERR! node -v v4.4.4
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok 
npm ERR! Linux 3.10.0-042stab111.12
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "node-gd"
npm ERR! node v4.4.4
npm ERR! npm  v2.15.1
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the node-gd package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs node-gd
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! 
npm ERR!     npm owner ls node-gd
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/user/workspace/dashboard/npm-debug.log

Alpine Linux support

Which environment-specific build tools shoud be installed on Alpine Linux?
I tried install make gcc python g++ gd-dev, but I get error during node-gyp build

[email protected] install /var/www/node_modules/node-gd
 node-gyp rebuild

gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | x64
gyp info spawn /usr/bin/python2
gyp info spawn args [ '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/var/www/node_modules/node-gd/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/root/.node-gyp/4.7.3/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/root/.node-gyp/4.7.3',
gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=node.lib',
gyp info spawn args   '-Dmodule_root_dir=/var/www/node_modules/node-gd',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
gdlib-config: warning: this script is deprecated; please use the pkg-config file instead.
gyp: Call to './util.sh GD_PNG' returned exit status 0 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:305:16)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:12)
gyp ERR! System Linux 4.4.0-64-generic
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /var/www/node_modules/node-gd
gyp ERR! node -v v4.7.3
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok 
npm info [email protected] Failed to exec install script
npm ERR! Linux 4.4.0-64-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v4.7.3
npm ERR! npm  v2.15.11
npm ERR! code ELIFECYCLE

Get raw image data for use in Buffer

Is there an easy implementation to get the data from an image? Currently, I'm using .saveImage() and then the result from fs.readFileSync to initialize a Buffer to use the image as an email attachment.

I need to access the raw data without the temporarily saving the image, reading it, then deleting it.

Windows support

How come this library doesn't build on Windows?
Because libgd clearly does support Windows

Node.js 4.x.x compatibility

Hello,
is this package compatible with Node.js 4.x.x?
I seen that on travis.ci You build only on "0.12" and "0.10".
I ask because I have a package that use node-gd as a dependency and I like it to work on last Node.js version.

Passing .png encoded as .jpg does not throw error

Was sent a .jpg image, needed it .png. When downloading the image from Gmail, set format to All Files:

screen shot 2017-09-12 at 3 38 27 pm

Changed extension from .jpg to .png:

screen shot 2017-09-12 at 3 38 35 pm

Having been passing this file which I assumed to be a .png into gd.openPng(), when the img being passed gets to the next method it's used by img.colorAllocate() received error:
"Cannot read property 'colorAllocate' of null". Took me awhile to come to the conclusion it was originally a .jpg that had its extension changed and gd.openPng() couldn't read it because it wasn't encoded as a .png.

node-gyp fails because of util.sh check even after dependencies

I've noticed that even after installing all of the dependencies-- specifically "gd" on an AWS EC2 running Ubuntu 14.04 using the command sudo apt-get install libgd2-dev # libgd, node-gyp throws the following error when using _npm install node-gd_

Package gdlib was not found in the pkg-config search path. 
Perhaps you should add the directory containing `gdlib.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gdlib' found

What I decided to do was to clone the entire node-gd repo and comment out everything util.sh leaving only echo true, then proceed to run _npm install_. This would ultimately install node-gd without an issue.

Just thought I would bring it to your attention. I'm not too familiar with the libgd package and I figure maybe the package gets installed differently with later versions and that the check within util.sh may need to be altered.

How to write japanese symbol 零

Hi there,

I'm using Noto Sans as font family and this font covers all almost all characters over the globe, Japanese included. How can I write 零 (symbol for zero) into an image?

const initials = '零';
canvas.stringFTEx(color, font, fontSize, 0, Math.floor((width - w) / 2), Math.floor((height / 2) + (h / 2)), initials, {
    charmap: 'unicode'
});

But I am ending with the unrecognized symbol...
download

Install fails on Ubuntu machine

I had no issues installing this package in my local Ubuntu VM (running Ubuntu 16.04), but for some reason, when trying to install on my server (also Ubuntu 16.04) it fails. I've installed libgd2-dev, as stated in the README.

Running npm install node-gd gives the classic, wonderfully-useless error:

npm ERR! Linux 4.8.0-56-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "node-gd"
npm ERR! node v4.2.6
npm ERR! npm  v3.5.2
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the node-gd package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs node-gd
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls node-gd
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR!     /home/seandohring/space_bot/npm-debug.log

npm-debug.log can be found here

squareToCircle not working

i want to crop an image to circle
i create transparent image i squareToCircle my image and i copy it to the one i created but it's not working

node 6.1 - v8::ObjectTemplate::Set() with non-primitive values is deprecated

After upgrade to node v6 I get the following error:

(node) v8::ObjectTemplate::Set() with non-primitive values is deprecated
(node) and will stop working in the next major release.

==== JS stack trace =========================================
bla bla bla

==== C stack trace ===============================

 1: v8::Template::Set(v8::Local<v8::Name>, v8::Local<v8::Data>, v8::PropertyAttribute)
 2: Gd::Image::Init(v8::Local<v8::Object>)
 3: Gd::Init(v8::Local<v8::Object>)
 4: node::DLOpen(v8::FunctionCallbackInfo<v8::Value> const&)
 5: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&))
 6: 0x7065aa
 7: 0x70690c
 8: 0x1bacde30961b

It seems that everything is working now, but I'm afraid that it can stop working in near future.

Error loading built node-gd

Updating my package.json with the master branch of node-gd builds just fine now (improvement from deprecation warnings [Issue 44]), however when I try to run it, i'm getting an error:

/home/sean/dev1_node6/matzah/node_modules/node-gd/build/Release/node_gd.node: undefined symbol: _ZN2Gd5Image4TiffERKN3Nan20FunctionCallbackInfoIN2v85ValueEEE Cannot find module '/home/sean/dev1_node6/matzah/node_modules/node-gd/js/../build/default/node_gd.node' Unable to find addon node_gd.node in build directory.

imageCopy not working

Behavior: image copy does not work if the two images are different, but it works if image is the same.

I have spend two days to figure out why, but I failed and started to think that this is a bug since it works in some cases only (same image case).

var gd = require('node-gd');
var output = 'image-watermark.png';

var watermark = gd.createFromPng('watermark.png');
var input = gd.createFromPng('input.png');

watermark.alphaBlending(1);
watermark.saveAlpha(1);

var final = watermark.copy(input,0,0,0,0,100,100); // This does NOT work
//var final = watermark.copy(watermark,0,0,0,0,100,100); // This does WORK

final.savePng(output, 0, function(error) {
});

gd.openFile is not a function

This only seems to occur in the 6.2.2 Node.js Docker container. Full source code and stuff is here, works fine under 6.2.2 on my local Arch install.

npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm info lifecycle [email protected]~prestart: [email protected]
npm info lifecycle [email protected]~start: [email protected]

> [email protected] start /usr/src/banner
> node index.js

/usr/src/banner/lib/generator.js:18
    gd.openFile('template/image/' + template + ".png", function(err, img) {
       ^

TypeError: gd.openFile is not a function
    at image (/usr/src/banner/lib/generator.js:18:8)
    at /usr/src/banner/lib/generator.js:47:17
    at Object.callback (/usr/src/banner/lib/generator.js:13:13)
    at Class.module.exports.Class.extend.done (/usr/src/banner/node_modules/gamedig/protocols/core.js:75:42)
    at Class.module.exports.Class.extend.fatal (/usr/src/banner/node_modules/gamedig/protocols/core.js:35:8)
    at Socket.<anonymous> (/usr/src/banner/node_modules/gamedig/protocols/core.js:242:21)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at TCP._handle.close [as _onclose] (net.js:492:12)

npm info lifecycle [email protected]~start: Failed to exec start script
npm ERR! Linux 3.16.0-4-amd64
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v6.2.2
npm ERR! npm  v3.9.5
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: `node index.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] start script 'node index.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the minecraftbanner package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node index.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs minecraftbanner
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls minecraftbanner
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /usr/src/banner/npm-debug.log

Is it squareToCircle has BUGS?

const gd = require('node-gd');
gd.openPng(IMAGE_DIR + '1467804398519.png', function(err, avatar){
    avatar
        .saveAlpha(1)
        .alphaBlending(1)
        .squareToCircle(100);
        avatar.savePng(IMAGE_DIR + "test.png");
});

after do this, test.png is the same as original怂
The png size : 256x256,
node-gd ver : 1.3.1
GD ver: 2.1.1

Getting 22 warnings about NewInstance const being deprecated

Using Node 6.10.0 and Node-gyp 3.3.1

-> [email protected] install /home/sean/dev1_node6/moth/node_modules/node-gd
-> node-gyp rebuild

make: Entering directory '/home/sean/dev1_node6/moth/node_modules/node-gd/build'
CXX(target) Release/obj.target/node_gd/cpp/addon.o
In file included from ../cpp/node_gd.cc:27:0,
from ../cpp/addon.cc:3:
../cpp/createworker.cc: In member function ā€˜virtual void CreateWorker::HandleOKCallback()ā€™:
../cpp/createworker.cc:34:80: warning: ā€˜v8::Localv8::Object v8::Function::NewInstance(int, v8::Localv8::Value) constā€™ is deprecated (declared at /home/sean/.node-gyp/6.10.0/include/node/v8.h:3269): Use maybe version [-Wdeprecated-declarations]
v8::Localv8::Object _image = func->GetFunction()->NewInstance(1, &arg);
^
In file included from ../cpp/addon.cc:3:0:
../cpp/node_gd.cc: In static member function ā€˜static Nan::NAN_METHOD_RETURN_TYPE Gd::ImageCreateSync(Nan::NAN_METHOD_ARGS_TYPE)ā€™:
../cpp/node_gd.cc:144:74: warning: ā€˜v8::Localv8::Object v8::Function::NewInstance(int, v8::Localv8::Value
) constā€™ is deprecated (declared at /home/sean/.node-gyp/6.10.0/include/node/v8.h:3269): Use maybe version [-Wdeprecated-declarations]
Local instance = func->GetFunction()->NewInstance(argc, &argv);
^
../cpp/node_gd.cc:311:3: note: in expansion of macro ā€˜RETURN_IMAGEā€™
RETURN_IMAGE(im);
^
../cpp/node_gd.cc: In static member function ā€˜static Nan::NAN_METHOD_RETURN_TYPE Gd::ImageCreateTrueColorSync(Nan::NAN_METHOD_ARGS_TYPE)ā€™:
../cpp/node_gd.cc:144:74: warning: ā€˜v8::Localv8::Object v8::Function::NewInstance(int, v8::Localv8::Value) constā€™ is deprecated (declared at /home/sean/.node-gyp/6.10.0/include/node/v8.h:3269): Use maybe version [-Wdeprecated-declarations]
Local instance = func->GetFunction()->NewInstance(argc, &argv);
^
../cpp/node_gd.cc:340:3: note: in expansion of macro ā€˜RETURN_IMAGEā€™
RETURN_IMAGE(im);
^
../cpp/node_gd.cc: In static member function ā€˜static Nan::NAN_METHOD_RETURN_TYPE Gd::CreateFromJpeg(Nan::NAN_METHOD_ARGS_TYPE)ā€™:
../cpp/node_gd.cc:144:74: warning: ā€˜v8::Localv8::Object v8::Function::NewInstance(int, v8::Localv8::Value) constā€™ is deprecated (declared at /home/sean/.node-gyp/6.10.0/include/node/v8.h:3269): Use maybe version [-Wdeprecated-declarations]
Local instance = func->GetFunction()->NewInstance(argc, &argv);
^
../cpp/node_gd.cc:154:5: note: in expansion of macro ā€˜RETURN_IMAGEā€™
RETURN_IMAGE(im)
^
../cpp/node_gd.cc:343:1: note: in expansion of macro ā€˜DECLARE_CREATE_FROMā€™
DECLARE_CREATE_FROM(Jpeg)
^
../cpp/node_gd.cc: In static member function ā€˜static Nan::NAN_METHOD_RETURN_TYPE Gd::CreateFromJpegPtr(Nan::NAN_METHOD_ARGS_TYPE)ā€™:
../cpp/node_gd.cc:144:74: warning: ā€˜v8::Localv8::Object v8::Function::NewInstance(int, v8::Localv8::Value) constā€™ is deprecated (declared at /home/sean/.node-gyp/6.10.0/include/node/v8.h:3269): Use maybe version [-Wdeprecated-declarations]
Local instance = func->GetFunction()->NewInstance(argc, &argv);
^
../cpp/node_gd.cc:173:5: note: in expansion of macro ā€˜RETURN_IMAGEā€™
RETURN_IMAGE(im)
^
../cpp/node_gd.cc:343:1: note: in expansion of macro ā€˜DECLARE_CREATE_FROMā€™
DECLARE_CREATE_FROM(Jpeg)
^
../cpp/node_gd.cc: In static member function ā€˜static Nan::NAN_METHOD_RETURN_TYPE Gd::CreateFromPng(Nan::NAN_METHOD_ARGS_TYPE)ā€™:
../cpp/node_gd.cc:144:74: warning: ā€˜v8::Localv8::Object v8::Function::NewInstance(int, v8::Localv8::Value) constā€™ is deprecated (declared at /home/sean/.node-gyp/6.10.0/include/node/v8.h:3269): Use maybe version [-Wdeprecated-declarations]
Local instance = func->GetFunction()->NewInstance(argc, &argv);
^
../cpp/node_gd.cc:154:5: note: in expansion of macro ā€˜RETURN_IMAGEā€™
RETURN_IMAGE(im)
^
../cpp/node_gd.cc:344:1: note: in expansion of macro ā€˜DECLARE_CREATE_FROMā€™
DECLARE_CREATE_FROM(Png)
^
../cpp/node_gd.cc: In static member function ā€˜static Nan::NAN_METHOD_RETURN_TYPE Gd::CreateFromPngPtr(Nan::NAN_METHOD_ARGS_TYPE)ā€™:
../cpp/node_gd.cc:144:74: warning: ā€˜v8::Localv8::Object v8::Function::NewInstance(int, v8::Localv8::Value) constā€™ is deprecated (declared at /home/sean/.node-gyp/6.10.0/include/node/v8.h:3269): Use maybe version [-Wdeprecated-declarations]
Local instance = func->GetFunction()->NewInstance(argc, &argv);
^
../cpp/node_gd.cc:173:5: note: in expansion of macro ā€˜RETURN_IMAGEā€™
RETURN_IMAGE(im)
^
../cpp/node_gd.cc:344:1: note: in expansion of macro ā€˜DECLARE_CREATE_FROMā€™
DECLARE_CREATE_FROM(Png)
^
../cpp/node_gd.cc: In static member function ā€˜static Nan::NAN_METHOD_RETURN_TYPE Gd::CreateFromGif(Nan::NAN_METHOD_ARGS_TYPE)ā€™:
../cpp/node_gd.cc:144:74: warning: ā€˜v8::Localv8::Object v8::Function::NewInstance(int, v8::Localv8::Value) constā€™ is deprecated (declared at /home/sean/.node-gyp/6.10.0/include/node/v8.h:3269): Use maybe version [-Wdeprecated-declarations]
Local instance = func->GetFunction()->NewInstance(argc, &argv);
^
../cpp/node_gd.cc:154:5: note: in expansion of macro ā€˜RETURN_IMAGEā€™
RETURN_IMAGE(im)
^
../cpp/node_gd.cc:345:1: note: in expansion of macro ā€˜DECLARE_CREATE_FROMā€™
DECLARE_CREATE_FROM(Gif)
^
../cpp/node_gd.cc: In static member function ā€˜static Nan::NAN_METHOD_RETURN_TYPE Gd::CreateFromGifPtr(Nan::NAN_METHOD_ARGS_TYPE)ā€™:
../cpp/node_gd.cc:144:74: warning: ā€˜v8::Localv8::Object v8::Function::NewInstance(int, v8::Localv8::Value) constā€™ is deprecated (declared at /home/sean/.node-gyp/6.10.0/include/node/v8.h:3269): Use maybe version [-Wdeprecated-declarations]
Local instance = func->GetFunction()->NewInstance(argc, &argv);
^
../cpp/node_gd.cc:173:5: note: in expansion of macro ā€˜RETURN_IMAGEā€™
RETURN_IMAGE(im)
^
../cpp/node_gd.cc:345:1: note: in expansion of macro ā€˜DECLARE_CREATE_FROMā€™
DECLARE_CREATE_FROM(Gif)
^
../cpp/node_gd.cc: In static member function ā€˜static Nan::NAN_METHOD_RETURN_TYPE Gd::CreateFromGd2(Nan::NAN_METHOD_ARGS_TYPE)ā€™:
../cpp/node_gd.cc:144:74: warning: ā€˜v8::Localv8::Object v8::Function::NewInstance(int, v8::Localv8::Value) constā€™ is deprecated (declared at /home/sean/.node-gyp/6.10.0/include/node/v8.h:3269): Use maybe version [-Wdeprecated-declarations]
Local instance = func->GetFunction()->NewInstance(argc, &argv);
^
../cpp/node_gd.cc:154:5: note: in expansion of macro ā€˜RETURN_IMAGEā€™
RETURN_IMAGE(im)
^
../cpp/node_gd.cc:346:1: note: in expansion of macro ā€˜DECLARE_CREATE_FROMā€™
DECLARE_CREATE_FROM(Gd2)
^
../cpp/node_gd.cc: In static member function ā€˜static Nan::NAN_METHOD_RETURN_TYPE Gd::CreateFromGd2Ptr(Nan::NAN_METHOD_ARGS_TYPE)ā€™:
../cpp/node_gd.cc:144:74: warning: ā€˜v8::Localv8::Object v8::Function::NewInstance(int, v8::Localv8::Value) constā€™ is deprecated (declared at /home/sean/.node-gyp/6.10.0/include/node/v8.h:3269): Use maybe version [-Wdeprecated-declarations]
Local instance = func->GetFunction()->NewInstance(argc, &argv);
^
../cpp/node_gd.cc:173:5: note: in expansion of macro ā€˜RETURN_IMAGEā€™
RETURN_IMAGE(im)
^
../cpp/node_gd.cc:346:1: note: in expansion of macro ā€˜DECLARE_CREATE_FROMā€™
DECLARE_CREATE_FROM(Gd2)
^
../cpp/node_gd.cc: In static member function ā€˜static Nan::NAN_METHOD_RETURN_TYPE Gd::CreateFromWBMP(Nan::NAN_METHOD_ARGS_TYPE)ā€™:
../cpp/node_gd.cc:144:74: warning: ā€˜v8::Localv8::Object v8::Function::NewInstance(int, v8::Localv8::Value) constā€™ is deprecated (declared at /home/sean/.node-gyp/6.10.0/include/node/v8.h:3269): Use maybe version [-Wdeprecated-declarations]
Local instance = func->GetFunction()->NewInstance(argc, &argv);
^
../cpp/node_gd.cc:154:5: note: in expansion of macro ā€˜RETURN_IMAGEā€™
RETURN_IMAGE(im)
^
../cpp/node_gd.cc:347:1: note: in expansion of macro ā€˜DECLARE_CREATE_FROMā€™
DECLARE_CREATE_FROM(WBMP)
^
../cpp/node_gd.cc: In static member function ā€˜static Nan::NAN_METHOD_RETURN_TYPE Gd::CreateFromWBMPPtr(Nan::NAN_METHOD_ARGS_TYPE)ā€™:
../cpp/node_gd.cc:144:74: warning: ā€˜v8::Localv8::Object v8::Function::NewInstance(int, v8::Localv8::Value) constā€™ is deprecated (declared at /home/sean/.node-gyp/6.10.0/include/node/v8.h:3269): Use maybe version [-Wdeprecated-declarations]
Local instance = func->GetFunction()->NewInstance(argc, &argv);
^
../cpp/node_gd.cc:173:5: note: in expansion of macro ā€˜RETURN_IMAGEā€™
RETURN_IMAGE(im)
^
../cpp/node_gd.cc:347:1: note: in expansion of macro ā€˜DECLARE_CREATE_FROMā€™
DECLARE_CREATE_FROM(WBMP)
^
../cpp/node_gd.cc: In static member function ā€˜static Nan::NAN_METHOD_RETURN_TYPE Gd::CreateFromBmp(Nan::NAN_METHOD_ARGS_TYPE)ā€™:
../cpp/node_gd.cc:144:74: warning: ā€˜v8::Localv8::Object v8::Function::NewInstance(int, v8::Localv8::Value) constā€™ is deprecated (declared at /home/sean/.node-gyp/6.10.0/include/node/v8.h:3269): Use maybe version [-Wdeprecated-declarations]
Local instance = func->GetFunction()->NewInstance(argc, &argv);
^
../cpp/node_gd.cc:154:5: note: in expansion of macro ā€˜RETURN_IMAGEā€™
RETURN_IMAGE(im)
^
../cpp/node_gd.cc:353:1: note: in expansion of macro ā€˜DECLARE_CREATE_FROMā€™
DECLARE_CREATE_FROM(Bmp);
^
../cpp/node_gd.cc: In static member function ā€˜static Nan::NAN_METHOD_RETURN_TYPE Gd::CreateFromBmpPtr(Nan::NAN_METHOD_ARGS_TYPE)ā€™:
../cpp/node_gd.cc:144:74: warning: ā€˜v8::Localv8::Object v8::Function::NewInstance(int, v8::Localv8::Value) constā€™ is deprecated (declared at /home/sean/.node-gyp/6.10.0/include/node/v8.h:3269): Use maybe version [-Wdeprecated-declarations]
Local instance = func->GetFunction()->NewInstance(argc, &argv);
^
../cpp/node_gd.cc:173:5: note: in expansion of macro ā€˜RETURN_IMAGEā€™
RETURN_IMAGE(im)
^
../cpp/node_gd.cc:353:1: note: in expansion of macro ā€˜DECLARE_CREATE_FROMā€™
DECLARE_CREATE_FROM(Bmp);
^
../cpp/node_gd.cc: In static member function ā€˜static Nan::NAN_METHOD_RETURN_TYPE Gd::CreateFromGd2Part(Nan::NAN_METHOD_ARGS_TYPE)ā€™:
../cpp/node_gd.cc:144:74: warning: ā€˜v8::Localv8::Object v8::Function::NewInstance(int, v8::Localv8::Value) constā€™ is deprecated (declared at /home/sean/.node-gyp/6.10.0/include/node/v8.h:3269): Use maybe version [-Wdeprecated-declarations]
Local instance = func->GetFunction()->NewInstance(argc, &argv);
^
../cpp/node_gd.cc:381:3: note: in expansion of macro ā€˜RETURN_IMAGEā€™
RETURN_IMAGE(im);
^
../cpp/node_gd.cc: In static member function ā€˜static Nan::NAN_METHOD_RETURN_TYPE Gd::CreateFromGd2PartPtr(Nan::NAN_METHOD_ARGS_TYPE)ā€™:
../cpp/node_gd.cc:144:74: warning: ā€˜v8::Localv8::Object v8::Function::NewInstance(int, v8::Localv8::Value) constā€™ is deprecated (declared at /home/sean/.node-gyp/6.10.0/include/node/v8.h:3269): Use maybe version [-Wdeprecated-declarations]
Local instance = func->GetFunction()->NewInstance(argc, &argv);
^
../cpp/node_gd.cc:399:3: note: in expansion of macro ā€˜RETURN_IMAGEā€™
RETURN_IMAGE(im);
^
../cpp/node_gd.cc: In static member function ā€˜static Nan::NAN_METHOD_RETURN_TYPE Gd::Image::Crop(Nan::NAN_METHOD_ARGS_TYPE)ā€™:
../cpp/node_gd.cc:144:74: warning: ā€˜v8::Localv8::Object v8::Function::NewInstance(int, v8::Localv8::Value) constā€™ is deprecated (declared at /home/sean/.node-gyp/6.10.0/include/node/v8.h:3269): Use maybe version [-Wdeprecated-declarations]
Local instance = func->GetFunction()->NewInstance(argc, &argv);
^
../cpp/node_gd.cc:2002:3: note: in expansion of macro ā€˜RETURN_IMAGEā€™
RETURN_IMAGE(newImage);
^
../cpp/node_gd.cc: In static member function ā€˜static Nan::NAN_METHOD_RETURN_TYPE Gd::Image::CropAuto(Nan::NAN_METHOD_ARGS_TYPE)ā€™:
../cpp/node_gd.cc:144:74: warning: ā€˜v8::Localv8::Object v8::Function::NewInstance(int, v8::Localv8::Value) constā€™ is deprecated (declared at /home/sean/.node-gyp/6.10.0/include/node/v8.h:3269): Use maybe version [-Wdeprecated-declarations]
Local instance = func->GetFunction()->NewInstance(argc, &argv);
^
../cpp/node_gd.cc:2016:3: note: in expansion of macro ā€˜RETURN_IMAGEā€™
RETURN_IMAGE(newImage);
^
../cpp/node_gd.cc: In static member function ā€˜static Nan::NAN_METHOD_RETURN_TYPE Gd::Image::CropThreshold(Nan::NAN_METHOD_ARGS_TYPE)ā€™:
../cpp/node_gd.cc:144:74: warning: ā€˜v8::Localv8::Object v8::Function::NewInstance(int, v8::Localv8::Value) constā€™ is deprecated (declared at /home/sean/.node-gyp/6.10.0/include/node/v8.h:3269): Use maybe version [-Wdeprecated-declarations]
Local instance = func->GetFunction()->NewInstance(argc, &argv);
^
../cpp/node_gd.cc:2026:3: note: in expansion of macro ā€˜RETURN_IMAGEā€™
RETURN_IMAGE(newImage);
^
../cpp/node_gd.cc: In static member function ā€˜static Nan::NAN_METHOD_RETURN_TYPE Gd::Image::SquareToCircle(Nan::NAN_METHOD_ARGS_TYPE)ā€™:
../cpp/node_gd.cc:144:74: warning: ā€˜v8::Localv8::Object v8::Function::NewInstance(int, v8::Localv8::Value) constā€™ is deprecated (declared at /home/sean/.node-gyp/6.10.0/include/node/v8.h:3269): Use maybe version [-Wdeprecated-declarations]
Local instance = func->GetFunction()->NewInstance(argc, &argv);
^
../cpp/node_gd.cc:2168:3: note: in expansion of macro ā€˜RETURN_IMAGEā€™
RETURN_IMAGE(newImage);
^
../cpp/node_gd.cc: In static member function ā€˜static Nan::NAN_METHOD_RETURN_TYPE Gd::Image::CreatePaletteFromTrueColor(Nan::NAN_METHOD_ARGS_TYPE)ā€™:
../cpp/node_gd.cc:144:74: warning: ā€˜v8::Localv8::Object v8::Function::NewInstance(int, v8::Localv8::Value) constā€™ is deprecated (declared at /home/sean/.node-gyp/6.10.0/include/node/v8.h:3269): Use maybe version [-Wdeprecated-declarations]
Local instance = func->GetFunction()->NewInstance(argc, &argv);
^
../cpp/node_gd.cc:2189:3: note: in expansion of macro ā€˜RETURN_IMAGEā€™
RETURN_IMAGE(newImage);
^
SOLINK_MODULE(target) Release/obj.target/node_gd.node
COPY Release/node_gd.node
make: Leaving directory '/home/sean/dev1_node6/moth/node_modules/node-gd/build

How to center align text using node-gd

Hello. I use node-gd for development some image processing project. I have a question for dev.

I want to composite multiple texts on some image. And Also the text is aligned center. but gd.Image#stringFT(color, font, size, angle, x, y, string, boundingbox) doesn't support text align.
I want multiline text align like gd-text setTextAlign('center', 'center'); method.

Would you tell me some good idea?
Thanks.

stringFTBBox() return elements

Hi again,

This is more like a discussion than an issue. stringFTBBox() currently according to the docs returns 8 (!) elements: [xll, yll, xlr, ylr, xur, yur, xul, yul]. Is there really a need for all 8 elements? Can the bounding box be anything else than a rectangle? If it is always rectangle, we need only 4 elements - x, y, width and height. I think it would make the API a bit more clear.

Regards,
Ivan

failing: "node-gyp rebuild"

Just an fyi. :-)

npm install node-gd --save
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN prefer global [email protected] should be installed with -g

> [email protected] install /Users/mikael/dev/lab/test/node_modules/node-gd
> node-gyp rebuild

./util.sh: line 2: pkg-config: command not found
gyp: Call to './util.sh png16' returned exit status 0 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:305:16)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12)
gyp ERR! System Darwin 15.5.0
gyp ERR! command "/usr/local/Cellar/node/6.2.2/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/mikael/dev/lab/test/node_modules/node-gd
gyp ERR! node -v v6.2.2
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok 
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm ERR! Darwin 15.5.0
npm ERR! argv "/usr/local/Cellar/node/6.2.2/bin/node" "/usr/local/bin/npm" "install" "node-gd" "--save"
npm ERR! node v6.2.2
npm ERR! npm  v3.10.2
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the node-gd package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs node-gd
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls node-gd
npm ERR! There is likely additional logging output above.

Failed Installation on MacOS

Hello. I installed node-gd recently on MacOS Sierra(10.12.6). But Installation was failed.
This is NPM installation logs. (NPM Version 5.4.0)

// npm install node-gd
/bin/sh: ./util.sh: Permission denied
gyp: Call to './util.sh png16' returned exit status 126 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:336:16)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Darwin 16.7.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/Momo/WebstormProjects/node-gd-sample/node_modules/node-gd
gyp ERR! node -v v6.9.2
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok 

So I tried to sudo command together.

// sudo npm install node-gd
> [email protected] install /Users/Momo/WebstormProjects/node-gd-sample/node_modules/node-gd
> node-gyp rebuild

gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/Users/Momo/WebstormProjects/node-gd-sample/node_modules/node-gd/build'
gyp ERR! stack     at Error (native)
gyp ERR! System Darwin 16.7.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/Momo/WebstormProjects/node-gd-sample/node_modules/node-gd
gyp ERR! node -v v6.9.2
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok 

I solved installation problem using yarn, yarn add node-gd. It is fine. But, yet I don`t install using NPM. I guess node-gyp rebuild command include permission issue.

Thanks.

Transparent background not working

I've been trying to create transparent background in node-gd but haven't had much success, here's what I have so far but each time I run this, it generates black backgrounds instead of transparent background. Any ideas? I believe this may be an issue.

var gd = require('node-gd');
var img = gd.createTrueColorSync(420, 116);
img.filledRectangle(0,0,420,116, gd.trueColorAlpha(255, 255, 255, 127));
img.savePng('output.png', 1, function(err) {
  if(err) {
    throw err;
  }
});
img.destroy();

Which generates this:

output

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.