aheckmann / gm Goto Github PK
View Code? Open in Web Editor NEWGraphicsMagick for node
Home Page: http://aheckmann.github.com/gm/
GraphicsMagick for node
Home Page: http://aheckmann.github.com/gm/
I'm trying to run a command equivalent to:
convert Foo.psd -flatten Foo.jpg
Is there any way as of right now to get this -flatten working? If not, where can I start poking around to add it?
Hi I've installed gm on server, with gif images it works fine, but when I use png image the error are thrown - "Command failed: gm identify: No decode delegate for this image format (/tmp/logo.png)". I've installed libpng and zlib but still have this error, what must I do to make it works???
Hello. Can I somehow get image blob after transformations without writing to filesystem? (I see write method all the time that writes to filesystem, but couldn't find method for getting image blob)
Can composite be added please? I need to composite one image on top of another at a specific location. I cannot figure out what to do from the source (looking at morph example).
Please advise. Thanks!
Edit: Also, the source image needs to be cropped and resized. Should this be done with 2 steps or can this be passed as args to the composite command?
Is there an option to use the ImageMagick binary instead of GraphicsMagick since the APIs are interchangeable?
Seeing this warning when I run "npm install" with gm >= 1.1.0 in my app's package.json. Did the format of the bugs section of package.json change?
Occurs for me whenever I draw any polygon, polyline, or bezier. These functions worked for me in previous versions.
If you look at those three methods in drawing.js it looks like the draw method is being passed an array of arguments rather than having the array of arguments .applied to it.
I fixed this for myself by changing:
return this.draw(["polyline"].concat(formatPoints(arguments)));
to
return this.draw.apply(this, ["polyline"].concat(formatPoints(arguments)));
for all three functions.
Hello,
Just to point out that I first try the module and had the following error:
Error: Command failed: execvp(): No such file or directory
Since I only had imagemagick installed, I tried installing graphicsmagick and everything ran smoothly.
Cheers
Error: spawn EMFILE
at errnoException (child_process.js:481:11)
at ChildProcess.spawn (child_process.js:444:11)
at child_process.js:342:9
at gm._spawn (/Users/myusername/node_modules/gm/lib/command.js:156:16)
at gm._exec (/Users/myusername/node_modules/gm/lib/command.js:137:17)
at gm.identify (/Users/myusername/node_modules/gm/lib/getters.js:74:10)
at gm.size (/Users/myusername/node_modules/gm/lib/getters.js:33:12)
.. attempted to walk a directory, getting image sizes for each image encountered.
Node: 0.6.12
OS: mac osx 10.6.8
I tried directly calling gm(<filename>).size(function(e, v){ ... });
on the last file in the list before the error, and it worked fine.
I created an array literal containing the 81 image filenames logged to the console leading up to the error and iterating over just them. Same result. But as soon as I removed any one of them from the array, everything was ok.
Currently gm.stream
will hang and the following error is reported:
Error: write EPIPE
at errnoException (net.js:646:11)
at Object.afterWrite [as oncomplete] (net.js:480:18)
It would be nice if the error is detected and an informative error returned to any callbacks.
As a new contributor, I couldn't figure out how to run the tests:
npm test
or
make test
failed. I'm not sure if it's because the tests themselves are not passing or if there is an extra step needed to get the test suite running that I did not complete. It would be nice to document that on the README so that new contributors can run the test suite.
When using ImageMagick, the identify method doesn't output correct EXIF data.
The problem is with the regex, because ImageMagick returns the EXIF data in this format:
exif:Model: Canon
You only end up with a "exif" property after executing identify.
Make sure it works
Hi,i run nodejs win32 binaries and get this error with gm :
{"0":
...
type:undefined,
message:"Command failed: execvp(): No such file of directory\n",
killed:false,
code:127,
...
"1" : "",
"2" : "execvp(): No such file or directory\n",
"3": "gm convert -size 420x220 ....
How can fix that.
Thanks
Thanks for the convenience library, works great. The only thing I'd wish for is a bit more flexibility regarding the resize options.
http://www.graphicsmagick.org/GraphicsMagick.html#details-geometry
To get the most out of it I think the function could be redefined something like:
// http://www.graphicsmagick.org/GraphicsMagick.html#details-resize
//valid arguments : width, height, options
proto.resize = function resize(args) {
var size;
size = "";
if (args.width != null) {
size += args.width;
}
size += "x";
if (args.height != null) {
size += args.height;
}
resize = size;
if (args.options != null) {
resize += args.options;
}
return this["in"]("-size", size).out("-resize", resize);
};
I am trying to get the tests to pass so that I have a good starting point but I am running into problems. Bellow is the output from the tests. How can I figure out what tests are failing?
$ node test/index.js
√√√√√√√√√√√√√√√√√√√√√√√√√√√√√√√√√√√░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
node.js:134
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Error: Command failed: execvp failed, errno = 2 (No such file or directory)
gm convert: "gs" "-q" "-dBATCH" "-dMaxBitmap=50000000" "-dNOPAUSE" "-sDEVICE=ppmraw" "-dTextAlphaBits=4" "-dGraphicsAlphaBits=4" "-r72x72" "-g680x136" "-sOutputFile=/var/folders/dm/y_gb705d3kz_x0rkrd7t36zw0000gn/T/gmPdl5eB" "--" "/var/folders/dm/y_gb705d3kz_x0rkrd7t36zw0000gn/T/gmV58OUO" "-c" "quit".
execvp failed, errno = 2 (No such file or directory)
gm convert: "gs" "-q" "-dBATCH" "-dMaxBitmap=50000000" "-dNOPAUSE" "-sDEVICE=ppmraw" "-dTextAlphaBits=4" "-dGraphicsAlphaBits=4" "-r72x72" "-g680x136" "-sOutputFile=/var/folders/dm/y_gb705d3kz_x0rkrd7t36zw0000gn/T/gmPdl5eB" "--" "/var/folders/dm/y_gb705d3kz_x0rkrd7t36zw0000gn/T/gmV58OUO" "-c" "quit".
gm convert: Postscript delegate failed (/var/folders/dm/y_gb705d3kz_x0rkrd7t36zw0000gn/T/gmIigJjO).
execvp failed, errno = 2 (No such file or directory)
gm convert: "gs" "-q" "-dBATCH" "-dMaxBitmap=50000000" "-dNOPAUSE" "-sDEVICE=ppmraw" "-dTextAlphaBits=4" "-dGraphicsAlphaBits
better validation of outcomes
Add The "trim" cmd to the docs and README.
http://www.graphicsmagick.org/GraphicsMagick.html#details-trim
Doing crop then resize on a JPEG image (PNG seems ok) results in:```
Command failed: gm convert: geometry does not contain image (unable to crop image).
Removing ```
in("-size", w +"x"+ h)
in lib/args.js:13 solves the issue, however I'm not sure about the deeper consequences.
Hi
I have got this error on [email protected]:
./node_modules/gm/index.js:59
var super = gm;
SyntaxError: <unknown message reserved_word>
Node version 0.6.7
Hey, I've been using GM for some time and am quite happy with how it makes my life easier :)
I've been trying to wrap my head around a new approach I'm trying and wondering why it isn't working as expected.
I'm using following code and want to push the stream to my amazon s3 bucket with aws2js module;
var readStream = fs.createReadStream('/path/to/my/img.png');
gm(readStream, 'img.png')
.stream(function (err, stdout, stderr) {
s3.putStream(path, stdout, 'public-read', {'content-type': 'image/png', 'content-length': ?????}, function (err, result) {
....
});
});
everything works fine with aws2js and streams, IF I know the content-length (when I just directly store the picture without resize). But when I don't specify the content-length, it doesnt work and my file ends up beeing 0bytes in size.
Since I'll be wanting to resize the picture and then send it to my bucket, I'll need to know how big the resized img will be.
Is there a way, how I can retrieve that information?
Thank you for your help in kicking me in the right direction :)
Hi,
I think the gm module should throw an error if graphicmagick is not installed on the system. It should atleast say that "Install graphicmagick or switch to Imagemagick".
Right now it just throws a cryptic error with a error code which on Googling translates into "Command not found".
Thanks
If I have a stream that is paused, pass it to gm
, then resume it, stream
gives an error:
var gm = require("gm");
var fs = require("fs");
var pause = require("connect").utils.pause;
var source = fs.createReadStream("img.png");
var pauser = pause(source);
setTimeout(function () {
gm(source, "img.png")
.resize(200, 200)
.stream("png", function (err, stdout, stderr) {
if (err) {
console.log("err", err);
process.exit(1);
} else {
stdout.pipe(process.stdout);
stderr.pipe(process.stderr);
}
});
pauser.resume();
}, 100);
$ node test.js
err [Error: gm().stream() or gm().write() with a non-readable stream. Pass "{bufferStream: true}" to identify() or getter (size, format, etc...)]
The problem is that the stream does indeed have readable: false
since it's already emitted all its events, which are caught by connect and stored in the _events
property to be re-emitted later, when I call pauser.resume()
.
So I guess it's partially connect's fault, since usually you can assume that non-readable streams will not emit any more events. But, a solution is kind of necessary, since there's otherwise no way to defer streaming image processing until after an asynchronous event (e.g. user authorization) has occurred. Note that the native stream's pause
method does not work on HTTP streams; data
events get dropped, necessitating something like connect's custom pause
function.
Not sure what a good solution is here. For now I've hacked around it by inserting source.readable = true
before calling gm
.
/cc @visionmedia for any connect-related advice, @isaacs since this is an interesting case of "unfuck HTTP"
I install gm on windows with npm.
When I run the 'thumb' example,I got the 'Error: Command failed: CreateProcessW: xxxxx' and 'code: 127, signal: null'
Dose gm support in windows?
not sure which test yet. after resolving this we can tag/release
stream.js:74
dest.end();
^
TypeError: Object [object Object] has no method 'end'
at Socket.onend (stream.js:74:10)
at Socket.emit (events.js:81:20)
at Socket._onReadable (net.js:652:51)
at IOWatcher.onReadable [as callback] (net.js:177:10)
make: *** [test] Error 1
When I installed gm with prefix I got this error
Command failed: gm identify: Unable to access configuration file (delegates.mgk) [No such file or directory].
Installing it without a prefix fixed that error but I now get errors like this when I try to open an image
code
gm(files.file.path).size(function (err, size) {
console.log(err);
console.log(size);
});
error
Command failed: gm identify: No decode delegate for this image format (/tmp/8c058c811a50b6441e98723c777b3199.JPG).
The parser for the identify output in getters.js gathers all the key=value pairs after the Image: header, but does not handle gathering the output for multiple images.
I've patched on my branch to make this return the output from the first image, because the first image in the series contains the correct canvas size.
I can either issue a pull request for this work-around, or I can make the parser gather the output for multiple images, or something else.
thoughts?
I'm using gm to downsample and crop images and am seeing this error fairly regularly, about 1% of requests. Making the same call a second time works just fine so it doesn't appear to be a problem with the inputs.
I realize it's internal to graphicsmagick but was hoping you might have some insight into what might be causing the issue and ways to alleviate the problem.
Could you add some helpfull methods for graphicsMagicks and ImageMagicks such as "setInterlaceScheme", "stripImage", "compositeImage", and "clone"?
Hi,
Is there any way to convert svg files into other formats (ex. png, jpg) using gm ?
Any help would be greatly appreciated.
Thanks
please add "gm composite" commond and “-background ” params ,thank you!
I want composite two pictures,so ...
Support for frame manipulation with animated GIF files.
Ability to remove frames, add frames, etc.
Ability to detect number of frames.
Ability to detect number of used pixels and pixel colors on a frame.
Hi,
I saved this file to my hard drive: http://www.prguitarman.com/comics/poptart1red1.gif
When I run this code:
gm(tmp_path).identify(function(err, data){
console.log(data);
});
I get this error?
[TypeError: Cannot set property 'Image' of undefined]
TypeError: Cannot set property 'Image' of undefined
at ChildProcess.<anonymous> (/home/user/abc/src/node_modules/gm/lib/getters.js:121:18)
at ChildProcess.<anonymous> (/home/user/abc/src/node_modules/gm/lib/command.js:208:18)
at ChildProcess.emit (events.js:70:17)
at maybeExit (child_process.js:361:16)
at Process.onexit (child_process.js:397:5)
I just want to determine if a file is animated gif or not, I don't necessarily need to perform any operations on that image.
thanks!
Hello-
This is not really an issue but more of a question. Is there a feasible way to store/retrieve the image data from/to memory instead of hitting the filesystem? It seems like this was possible in PHP but I don't remember for sure.
Thanks,
Matt
I am not sure what happens here but really weird.
Node v0.8.2 on Mac (unfortunately can not determine if I run GraphicsMagick or ImageMagick)
var gm = require('gm');
gm( __dirname + '/data/img/icons/favicon.png').size(function(err, size) {
console.log(size);
});
gm( __dirname + '/data/img/icons/favicon.png').size(function(err, size) {
console.log(size);
});
gm( __dirname + '/data/img/loading.gif').size(function(err, size) {
console.log(size);
});
gm( __dirname + '/data/img/loading.gif').size(function(err, size) {
console.log(size);
});
https://github.com/vanng822/jcash/blob/master/tests/data/img/icons/favicon.png
https://github.com/vanng822/jcash/blob/master/tests/data/img/loading.gif
-----node test.js, good output
{ width: 16, height: 16 }
{ width: 16, height: 16 }
{ width: 35, height: 35 }
{ width: 35, height: 35 }
-----node test.js
{ width: 16, height: 16 }
undefined
{ width: 35, height: 35 }
{ width: 35, height: 35 }
------ node test.js
{ width: 16, height: 16 }
undefined
{ width: 35, height: 35 }
{ width: 35, height: 35 }
------node test.js
{ width: 16, height: 16 }
undefined
{ width: 35, height: 35 }
{ width: 1, height: 1 }
The getterIdentify.js test is failing for me on line 15 due to what is perhaps a floating point rounding difference. Here is the output:
Jubilee:gm[master]$ make test
The "sys" module is now called "util". It should have a similar interface.
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
AssertionError: "71.71 (0.2812)" == "71.70 (0.2812)"
at gm.<anonymous> (/Users/joshua/Working/libraries/gm/test/getterIdentify.js:15:12)
at ChildProcess.<anonymous> (/Users/joshua/Working/libraries/gm/lib/getters.js:142:23)
at ChildProcess.<anonymous> (/Users/joshua/Working/libraries/gm/lib/command.js:207:18)
at ChildProcess.emit (events.js:70:17)
at maybeExit (child_process.js:360:16)
at Socket.<anonymous> (child_process.js:457:7)
at Socket.emit (events.js:67:17)
at Array.16 (net.js:335:10)
at EventEmitter._tickCallback (node.js:192:40)
make: *** [test] Error 1
This is on Node v0.6.14. Is anyone else having issues like this with the test suite?
I am using gm to create large images with many small items drawn on them (a map in a computer game). The problem is that beyond a certain number of operations I start to receive the error "Command failed: execvp(): Argument list too long". This can be reproduced with the following code:
var Gm = require('gm');
var image = Gm(100, 100, '#FFF');
for (var i = 0; i < 10000; i++) {
image.drawCircle(0,0,5,5);
}
image.write('test.gif', function(e) {
if (e) {
console.log('Error:');
console.log(e);
}
else {
console.log('Done.');
}
});
I am able to circumvent this issue by writing to file every few iterations, but this seems hacky because I never really know how much more 'argument room' is available and the constant writes really slows things down.
Given an image that is a animated gif, can GM disable the animation in gifs? What's the API command for it? Thanks!
How can I do that ?
Hey,
graphicsmagik returns IPTC data such as caption, GPS etc on the command line
gm identify -ping -verbose image.jpg
However the node gm identify wrapper only returns a subset of this data, even thought it uses the same command as above.
I believe only few changes will be needed to the parser that transforms stdout to JSON.
Would it be possible to add buffer as one of the options for gm? Reason I ask is because I'm reading a stream for a base64 encoded image and I create a new buffer from it, but since gm only accepts a string I have to write it to file first and then read the file instead of being able to go straight to gm with the buffer.
Thanks! ^^
I'm trying to scale an image in place. Is there any way to do something equivalent to:
gm mogrify -size 120x120 my-image.jpg -resize 120x120
Is it possible to pad out the thumbnail? Like shown here:
http://www.imagemagick.org/Usage/thumbnails/#pad
Error: Command failed: gm convert: Unable to open file (1) [No such file or directory].
It looks like the factor is getting passed in as a filename or something.
Hi,
I tried to resize image with gm but I got this error
[2012-06-05 03:02:58.648] [INFO] console - Error: Command failed: CreateProcessW: The system cannot find the file specified.
at ChildProcess.<anonymous> (C:\Users\user00492\workspace\inbrush\node_modules\gm\lib\command.js:203:17)
at ChildProcess.emit (events.js:70:17)
at maybeExit (child_process.js:362:16)
at Socket.<anonymous> (child_process.js:467:7)
at Socket.emit (events.js:67:17)
at Array.1 (net.js:335:10)
at EventEmitter._tickCallback (node.js:192:40)
I am using node v0.6.17 on windows 7, and this is my code
var gm = require('gm');
gm('C:/Users/user00492/default.jpg')
.resize(40, 40)
.noProfile()
.write(
'C:/Users/user00492/resized.jpg', function(err) {
if (!err)
console.log('done');
else
console.log(err)
});
Could anyone help me to fix this problem?
Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.