Comparing version 1.16.0 to 1.17.0
@@ -0,2 +1,13 @@ | ||
1.17.0 / 2014-10-28 | ||
================== | ||
* changed: extended compare callback also returns the file names #297 [mastix](https://github.com/mastix) | ||
* changed: pass spawn crash to callback #306 [medikoo](https://github.com/medikoo) | ||
* changed: geometry supports arbitary string as first argument #330 [jdiez17](https://github.com/jdiez17) | ||
* added: support for repage+ option #275 [desigens](https://github.com/desigens) | ||
* added: added the dissolve command #300 [microadm](https://github.com/microadam) | ||
* added: composite method #332 [jdiez17](https://github.com/jdiez17) | ||
* fixed: cannot set tolerance to 0 #302 [rwky](https://github.com/rwky) | ||
* fixed: handle empty buffers #330 [alcidesv](https://github.com/alcidesv) | ||
1.16.0 / 2014-05-09 | ||
@@ -3,0 +14,0 @@ ================== |
@@ -119,2 +119,3 @@ | ||
require("./lib/compare")(gm.prototype); | ||
require("./lib/composite")(gm.prototype); | ||
@@ -121,0 +122,0 @@ /** |
@@ -210,2 +210,7 @@ /** | ||
// http://www.graphicsmagick.org/GraphicsMagick.html#details-dissolve | ||
proto.dissolve = function dissolve (percent) { | ||
return this.out("-dissolve", percent+'%'); | ||
} | ||
// http://www.graphicsmagick.org/GraphicsMagick.html#details-encoding | ||
@@ -254,2 +259,7 @@ proto.encoding = function encoding (type) { | ||
proto.geometry = function geometry (width, height, arg) { | ||
// If the first argument is a string, and there is only one argument, this is a custom geometry command. | ||
if(arguments.length == 1 && typeof arguments[0] === "string") | ||
return this.out("-geometry", arguments[0]); | ||
// Otherwise, return a resizing geometry command with an option alrgument. | ||
return this.out("-geometry", width+'x'+height+(arg||'')); | ||
@@ -463,2 +473,3 @@ } | ||
proto.repage = function repage (width, height, xoff, yoff, arg) { | ||
if (arguments[0] === "+") return this.out("+repage"); | ||
return this.out("-repage", width+'x'+height+'+'+xoff+'+'+yoff+(arg||'')); | ||
@@ -465,0 +476,0 @@ } |
@@ -11,3 +11,2 @@ | ||
var series = require('array-series'); | ||
var streamToBuffer = require('stream-to-buffer'); | ||
@@ -48,3 +47,35 @@ /* | ||
} | ||
function streamToUnemptyBuffer(stream, callback) { | ||
var done = false | ||
var buffers = [] | ||
stream.on('data', function (data) { | ||
buffers.push(data) | ||
}) | ||
stream.on('end', function () { | ||
var result, err; | ||
if (done) | ||
return | ||
done = true | ||
result = Buffer.concat(buffers) | ||
buffers = null | ||
if (result.length==0) | ||
{ | ||
err = new Error("Stream yields empty buffer"); | ||
callback(err, null); | ||
} else { | ||
callback(null, result); | ||
} | ||
}) | ||
stream.on('error', function (err) { | ||
done = true | ||
buffers = null | ||
callback(err) | ||
}) | ||
} | ||
proto.in = args('_in'); | ||
@@ -144,3 +175,3 @@ proto.out = args('_out'); | ||
streamToBuffer(stdout, callback); | ||
streamToUnemptyBuffer(stdout, callback); | ||
}) | ||
@@ -179,3 +210,3 @@ } | ||
* @param {Boolean} shouldBuffer | ||
* @param {Function} callback | ||
* @param {Function} callback, signature (err, stdout, stderr) -> * | ||
* @return {Object} gm | ||
@@ -191,9 +222,14 @@ * @TODO refactor this mess | ||
var proc = spawn(bin, args) | ||
, cmd = bin + ' ' + args.map(utils.escape).join(' ') | ||
var cmd = bin + ' ' + args.map(utils.escape).join(' ') | ||
, self = this | ||
, err; | ||
, proc, err; | ||
debug(cmd); | ||
try { | ||
proc = spawn(bin, args); | ||
} catch (e) { | ||
return cb(e); | ||
} | ||
if (self.sourceBuffer) { | ||
@@ -222,3 +258,3 @@ proc.stdin.write(this.sourceBuffer); | ||
streamToBuffer(self.sourceStream, function (err, buffer) { | ||
streamToUnemptyBuffer(self.sourceStream, function (err, buffer) { | ||
self.sourceBuffer = buffer; | ||
@@ -225,0 +261,0 @@ self.sourceStream = null; // The stream is now dead |
@@ -30,3 +30,3 @@ // compare | ||
var execCmd = bin + 'compare -metric mse ' + orig + ' ' + compareTo; | ||
var tolerance = 0.4 | ||
var tolerance = 0.4; | ||
// outputting the diff image | ||
@@ -51,3 +51,3 @@ if (typeof options === 'object') { | ||
if (options.tolerance) { | ||
if (typeof options.tolerance != 'undefined') { | ||
if (typeof options.tolerance !== 'number') { | ||
@@ -93,3 +93,3 @@ throw new TypeError('The tolerance value should be a number'); | ||
var equality = parseFloat(match[1]); | ||
cb(null, equality <= tolerance, equality, stdout); | ||
cb(null, equality <= tolerance, equality, stdout, utils.unescape(orig), utils.unescape(compareTo)); | ||
}); | ||
@@ -96,0 +96,0 @@ } |
@@ -12,4 +12,8 @@ | ||
return '"' + String(arg).trim().replace(/"/g, '\\"') + '"'; | ||
} | ||
}; | ||
exports.unescape = function escape (arg) { | ||
return String(arg).trim().replace(/"/g, ""); | ||
}; | ||
exports.argsToArray = function (args) { | ||
@@ -24,2 +28,2 @@ var arr = []; | ||
return arr; | ||
} | ||
}; |
{ | ||
"name": "gm", | ||
"description": "GraphicsMagick and ImageMagick for node.js", | ||
"version": "1.16.0", | ||
"version": "1.17.0", | ||
"author": "Aaron Heckmann <aaron.heckmann+github@gmail.com>", | ||
@@ -46,5 +46,4 @@ "keywords": [ | ||
"array-parallel": "~0.1.0", | ||
"stream-to-buffer": "~0.0.1", | ||
"through": "~2.3.1" | ||
} | ||
} |
THIS REPOSITORY NEEDS A MAINTAINER. IF YOU'RE INTERESTED IN MAINTAING THIS MODULE, PLEASE LET US KNOW! | ||
# gm v1.17.0 [![Build Status](https://travis-ci.org/aheckmann/gm.png?branch=master)](https://travis-ci.org/aheckmann/gm) [![NPM Version](https://img.shields.io/npm/v/gm.svg?style=flat)](https://www.npmjs.org/package/gm) | ||
# gm v1.15.0 [![Build Status](https://travis-ci.org/aheckmann/gm.png?branch=master)](https://travis-ci.org/aheckmann/gm) | ||
GraphicsMagick and ImageMagick for node | ||
@@ -27,2 +25,18 @@ | ||
## Use ImageMagick instead of gm | ||
Just pass the option `{imageMagick: true}` to enable ImageMagick | ||
```js | ||
var fs = require('fs') | ||
, gm = require('./gm'); | ||
// resize and remove EXIF profile data | ||
gm('/path/to/my/img.jpg') | ||
.options({imageMagick: true}) | ||
.resize(240, 240) | ||
... | ||
``` | ||
## Basic Usage | ||
@@ -177,6 +191,9 @@ | ||
// A buffer can also be returned instead of a stream | ||
/* | ||
A buffer can also be returned instead of a stream | ||
The first argument to toBuffer is optional, it specifies the image format | ||
*/ | ||
gm('img.jpg') | ||
.resize(100, 100) | ||
.toBuffer(function (err, buffer) { | ||
.toBuffer('PNG',function (err, buffer) { | ||
if (err) return handle(err); | ||
@@ -329,2 +346,3 @@ console.log('done!'); | ||
- [dispose](http://aheckmann.github.com/gm/docs.html#dispose) | ||
- [dissolve](http://aheckmann.github.com/gm/docs.html#dissolve) | ||
- [edge](http://aheckmann.github.com/gm/docs.html#edge) | ||
@@ -494,3 +512,3 @@ - [emboss](http://aheckmann.github.com/gm/docs.html#emboss) | ||
```js | ||
gm.compare('/path/to/image1.jpg', '/path/to/another.png', function (err, isEqual, equality, raw) { | ||
gm.compare('/path/to/image1.jpg', '/path/to/another.png', function (err, isEqual, equality, raw, path1, path2) { | ||
if (err) return handle(err); | ||
@@ -505,3 +523,6 @@ | ||
// inspect the raw output | ||
console.log(raw) | ||
console.log(raw); | ||
// print file paths | ||
console.log(path1, path2); | ||
}) | ||
@@ -533,2 +554,19 @@ ``` | ||
##composite | ||
GraphicsMagick supports compositing one image on top of another. This is exposed through `gm.composite()`. Its first argument is an image path with the changes to the base image, and an optional mask image. | ||
Currently, `gm.composite()` only accepts file paths. | ||
gm.composite(other [, mask]) | ||
```js | ||
gm('/path/to/image.jpg') | ||
.composite('/path/to/second_image.jpg') | ||
.geometry('+100+150') | ||
.write('/path/to/composite.png', function(err) { | ||
if(!err) console.log("Written composite image."); | ||
}); | ||
``` | ||
## Contributors | ||
@@ -535,0 +573,0 @@ [https://github.com/aheckmann/gm/contributors](https://github.com/aheckmann/gm/contributors) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
107083
4
20
1974
599
5
- Removedstream-to-buffer@~0.0.1
- Removedstream-to-buffer@0.0.1(transitive)