From abc1f87ace1e1793f751990794647ffe25bd2f06 Mon Sep 17 00:00:00 2001 From: Ryan Wholey Date: Thu, 17 Sep 2015 21:56:28 -0700 Subject: [PATCH 01/64] Changed word 'reformated' to read 'reformatted' --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index aed0ff9f..bb6be3b1 100644 --- a/README.md +++ b/README.md @@ -159,12 +159,12 @@ gm('/path/to/my/img.jpg') // gm will provide image data in that format gm('/path/to/my/img.jpg') .stream('png', function (err, stdout, stderr) { - var writeStream = fs.createWriteStream('/path/to/my/reformated.png'); + var writeStream = fs.createWriteStream('/path/to/my/reformatted.png'); stdout.pipe(writeStream); }); // or without the callback -var writeStream = fs.createWriteStream('/path/to/my/reformated.png'); +var writeStream = fs.createWriteStream('/path/to/my/reformatted.png'); gm('/path/to/my/img.jpg') .stream('png') .pipe(writeStream); From de8b57dd41a24735b79203bdda07cdc8a609e0e1 Mon Sep 17 00:00:00 2001 From: Rowan Wookey Date: Wed, 23 Sep 2015 19:03:48 +0100 Subject: [PATCH 02/64] 1.20.0 --- History.md | 6 +++++- package.json | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/History.md b/History.md index c7e278e6..70d32a7c 100644 --- a/History.md +++ b/History.md @@ -1,4 +1,8 @@ -1.19 / 2015-09-16 +1.20.0 / 2015-09-23 + +* changed: Reverted "Add format inference from filename for buffers/streams" due to errors #448 + +1.19.0 / 2015-09-16 * changed: Added error to notify about image magick not supporting minify [encima](https://github.com/encima) * changed: Refactored orientation getter to use faster identify call [lbeschastny](https://github.com/lbeschastny) diff --git a/package.json b/package.json index 50dd723f..02e94672 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "gm", "description": "GraphicsMagick and ImageMagick for node.js", - "version": "1.19.0", + "version": "1.20.0", "author": "Aaron Heckmann ", "keywords": [ "graphics", From 5f5c77490aa84ed313405c88905eb4566135be31 Mon Sep 17 00:00:00 2001 From: Rowan Wookey Date: Mon, 26 Oct 2015 18:56:09 +0000 Subject: [PATCH 03/64] Fixed security issue with gm.compare where arguments aren't being escaped properly --- History.md | 4 ++++ lib/compare.js | 54 ++++++++++++++++++++++++++++-------------------- lib/composite.js | 2 -- lib/montage.js | 2 -- package.json | 2 +- 5 files changed, 37 insertions(+), 27 deletions(-) diff --git a/History.md b/History.md index 70d32a7c..ae2a467f 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,7 @@ +1.21.0 / 2015-10-26 **contains security fix** + +* fixed: gm.compare fails to escape arguments properly (Reported by Brendan Scarvell) [rwky](https://github.com/rwky) + 1.20.0 / 2015-09-23 * changed: Reverted "Add format inference from filename for buffers/streams" due to errors #448 diff --git a/lib/compare.js b/lib/compare.js index 07a56af2..35c8d51e 100644 --- a/lib/compare.js +++ b/lib/compare.js @@ -1,7 +1,6 @@ // compare -var exec = require('child_process').exec; -var utils = require('./utils'); +var spawn = require('child_process').spawn; /** * Compare two images uses graphicsmagicks `compare` command. @@ -20,13 +19,11 @@ var utils = require('./utils'); module.exports = exports = function (proto) { function compare(orig, compareTo, options, cb) { - orig = utils.escape(orig); - compareTo = utils.escape(compareTo); var isImageMagick = this._options && this._options.imageMagick; // compare binary for IM is `compare`, for GM it's `gm compare` var bin = isImageMagick ? '' : 'gm '; - var execCmd = bin + 'compare -metric mse ' + orig + ' ' + compareTo; + var args = ['compare', '-metric', 'mse', orig, compareTo] var tolerance = 0.4; // outputting the diff image if (typeof options === 'object') { @@ -40,16 +37,19 @@ module.exports = exports = function (proto) { throw new TypeError('The path for the diff output is invalid'); } // graphicsmagick defaults to red - var highlightColorOption = options.highlightColor - ? ' -highlight-color ' + options.highlightColor + ' ' - : ' '; - var highlightStyleOption = options.highlightStyle - ? ' -highlight-style ' + options.highlightStyle + ' ' - : ' '; - var diffFilename = utils.escape(options.file); + if (options.highlightColour) { + args.push('-highlight-color'); + args.push(options.highlightColor); + } + if (options.highlightStyle) { + args.push('-highlight-style') + args.push(options.highlightStyle) + } // For IM, filename is the last argument. For GM it's `-file ` - var diffOpt = isImageMagick ? diffFilename : ('-file ' + diffFilename); - execCmd += highlightColorOption + highlightStyleOption + ' ' + diffOpt; + if (isImageMagick) { + args.push('-file'); + } + args.push(options.file); } if (typeof options.tolerance != 'undefined') { @@ -60,7 +60,9 @@ module.exports = exports = function (proto) { } } else { // For ImageMagick diff file is required but we don't care about it, so null it out - isImageMagick && (execCmd += ' null:'); + if (isImageMagick) { + args.push('null:'); + } if (typeof options == 'function') { cb = options; // tolerance value not provided, flip the cb place @@ -69,19 +71,27 @@ module.exports = exports = function (proto) { } } - exec(execCmd, function (err, stdout, stderr) { + var proc = spawn('/usr/bin/gm', args); + var stdout = ''; + var stderr = ''; + proc.stdout.on('data',function(data) { stdout+=data }); + proc.stderr.on('data',function(data) { stderr+=data }); + proc.on('close', function (code) { // ImageMagick returns err code 2 if err, 0 if similar, 1 if dissimilar if (isImageMagick) { - if (!err) { + if (code === 0) { return cb(null, 0 <= tolerance, 0, stdout); } - if (err.code === 1) { + else if (code === 1) { err = null; stdout = stderr; + } else { + return cb(stderr); + } + } else { + if(code !== 0) { + return cb(stderr); } - } - if (err) { - return cb(err); } // Since ImageMagick similar gives err code 0 and no stdout, there's really no matching // Otherwise, output format for IM is `12.00 (0.123)` and for GM it's `Total: 0.123` @@ -93,7 +103,7 @@ module.exports = exports = function (proto) { } var equality = parseFloat(match[1]); - cb(null, equality <= tolerance, equality, stdout, utils.unescape(orig), utils.unescape(compareTo)); + cb(null, equality <= tolerance, equality, stdout, orig, compareTo); }); } diff --git a/lib/composite.js b/lib/composite.js index 069a3b94..ca90440f 100644 --- a/lib/composite.js +++ b/lib/composite.js @@ -1,7 +1,5 @@ // composite -var utils = require('./utils'); - /** * Composite images together using the `composite` command in graphicsmagick. * diff --git a/lib/montage.js b/lib/montage.js index 8e9ccc10..3120be84 100644 --- a/lib/montage.js +++ b/lib/montage.js @@ -1,7 +1,5 @@ // montage -var utils = require('./utils'); - /** * Montage images next to each other using the `montage` command in graphicsmagick. * diff --git a/package.json b/package.json index 02e94672..200f9c71 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "gm", "description": "GraphicsMagick and ImageMagick for node.js", - "version": "1.20.0", + "version": "1.21.0", "author": "Aaron Heckmann ", "keywords": [ "graphics", From 4ad863b0c4d774876cdbcf117cd9ae9319887cc4 Mon Sep 17 00:00:00 2001 From: Rowan Wookey Date: Mon, 26 Oct 2015 20:45:39 +0000 Subject: [PATCH 04/64] Fixed #465 hard coded gm binary, also fixed issues with compare and fixed tests so they will fail on subsequent runs when they should do --- lib/compare.js | 15 ++++++++++----- test/422.js | 6 ++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/compare.js b/lib/compare.js index 35c8d51e..bb1151c3 100644 --- a/lib/compare.js +++ b/lib/compare.js @@ -21,9 +21,14 @@ module.exports = exports = function (proto) { function compare(orig, compareTo, options, cb) { var isImageMagick = this._options && this._options.imageMagick; - // compare binary for IM is `compare`, for GM it's `gm compare` - var bin = isImageMagick ? '' : 'gm '; - var args = ['compare', '-metric', 'mse', orig, compareTo] + var appPath = this._options && this._options.appPath || ''; + var bin = isImageMagick + ? appPath + 'compare' + : appPath + 'gm' + var args = ['-metric', 'mse', orig, compareTo] + if (!isImageMagick) { + args.unshift('compare'); + } var tolerance = 0.4; // outputting the diff image if (typeof options === 'object') { @@ -46,7 +51,7 @@ module.exports = exports = function (proto) { args.push(options.highlightStyle) } // For IM, filename is the last argument. For GM it's `-file ` - if (isImageMagick) { + if (!isImageMagick) { args.push('-file'); } args.push(options.file); @@ -71,7 +76,7 @@ module.exports = exports = function (proto) { } } - var proc = spawn('/usr/bin/gm', args); + var proc = spawn(bin, args); var stdout = ''; var stderr = ''; proc.stdout.on('data',function(data) { stdout+=data }); diff --git a/test/422.js b/test/422.js index 1f0d29ef..583d9698 100644 --- a/test/422.js +++ b/test/422.js @@ -29,11 +29,13 @@ module.exports = function (gm, dir, finish, GM) { if (err) return finish(err); fs.exists(options.file, function(exists) { - if (exists) finish(); + if (exists) { + fs.unlink(options.file, finish); + } else finish(new Error('Diff file does not exist.')); }); }); }); }); }); -}; \ No newline at end of file +}; From d8e8d84b6e7a29a13dc88f191850908aa27ed6c5 Mon Sep 17 00:00:00 2001 From: Rowan Wookey Date: Mon, 26 Oct 2015 20:48:31 +0000 Subject: [PATCH 05/64] v1.21.1 --- History.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index ae2a467f..80584088 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,7 @@ +1.21.1 / 2015-10-26 + +* fixed: Fixed #465 hard coded gm binary, also fixed issues with compare and fixed tests so they will fail on subsequent runs when they should do [rwky](https://github.com/rwky) + 1.21.0 / 2015-10-26 **contains security fix** * fixed: gm.compare fails to escape arguments properly (Reported by Brendan Scarvell) [rwky](https://github.com/rwky) diff --git a/package.json b/package.json index 200f9c71..1b7170e8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "gm", "description": "GraphicsMagick and ImageMagick for node.js", - "version": "1.21.0", + "version": "1.21.1", "author": "Aaron Heckmann ", "keywords": [ "graphics", From d7c84e9eefa6eb5673beca60841931279f7a5ab2 Mon Sep 17 00:00:00 2001 From: Rodrigo Alviani Date: Tue, 1 Dec 2015 11:39:07 -0200 Subject: [PATCH 06/64] Fix typo --- lib/getters.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/getters.js b/lib/getters.js index 88317c5b..0c4729eb 100755 --- a/lib/getters.js +++ b/lib/getters.js @@ -221,7 +221,7 @@ module.exports = function (gm) { } else if (indent > level) { // dropping into a nested object out.indent[level] = o; - // wierd format, key/val pair with nested children. discard the val + // weird format, key/val pair with nested children. discard the val o = o[lastkey] = {}; } From a797086d89d40b2fa838aaa28c9fb443099c8bf1 Mon Sep 17 00:00:00 2001 From: yuta25 Date: Wed, 6 Jan 2016 19:09:41 +0900 Subject: [PATCH 07/64] Add dispose support --- lib/command.js | 55 ++++++++++++++++++++++++++++++++++++++++--------- test/dispose.js | 45 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 10 deletions(-) create mode 100644 test/dispose.js diff --git a/lib/command.js b/lib/command.js index 9811f739..9fd13a77 100644 --- a/lib/command.js +++ b/lib/command.js @@ -211,6 +211,7 @@ module.exports = function (proto) { , self = this , proc, err , timeout = parseInt(this._options.timeout) + , disposers = this._options.disposers , timeoutId; debug(cmd); @@ -228,15 +229,18 @@ module.exports = function (proto) { if (timeout) { timeoutId = setTimeout(function(){ - err = new Error('gm() resulted in a timeout.'); - cb(err); - if (proc.connected) { - proc.stdin.pause(); - proc.kill(); - } + dispose('gm() resulted in a timeout.'); }, timeout); } + if (disposers) { + disposers.forEach(function(disposer) { + disposer.events.forEach(function(event) { + disposer.emitter.on(event, dispose); + }); + }); + } + if (self.sourceBuffer) { proc.stdin.write(this.sourceBuffer); proc.stdin.end(); @@ -311,12 +315,22 @@ module.exports = function (proto) { if (cb.called) return; if (timeoutId) clearTimeout(timeoutId); cb.called = 1; - if (args[0] !== 'identify' && bin !== 'identify') { - self._in = []; - self._out = []; - } + if (args[0] !== 'identify' && bin !== 'identify') { + self._in = []; + self._out = []; + } callback.call(self, err, stdout, stderr, cmd); } + + function dispose (msg) { + var message = msg ? msg : 'gm() was disposed'; + err = new Error(message); + cb(err); + if (proc.exitCode === null) { + proc.stdin.pause(); + proc.kill(); + } + } } /** @@ -408,4 +422,25 @@ module.exports = function (proto) { return rgx.test(this.source); } + + /** + * add disposer (like 'close' of http.IncomingMessage) in order to dispose gm() with any event + * + * @param {EventEmitter} emitter + * @param {Array} events + * @return {Object} gm + * @example + * command.addDisposer(req, ['close', 'end', 'finish']); + */ + + proto.addDisposer = function addDisposer (emitter, events) { + if (!this._options.disposers) { + this._options.disposers = []; + } + this._options.disposers.push({ + emitter: emitter, + events: events + }); + return this; + }; } diff --git a/test/dispose.js b/test/dispose.js new file mode 100644 index 00000000..585cc742 --- /dev/null +++ b/test/dispose.js @@ -0,0 +1,45 @@ +var assert = require('assert'); + +module.exports = function (img, dir, finish, gm) { + var EventEmitter = require('events').EventEmitter; + EventEmitter.prototype._maxListeners = 100; + + assert.equal(undefined, gm.prototype._options.disposers); + assert.equal(undefined, img._options.disposers); + + emitter = new EventEmitter(); + + disposer = { + emitter: emitter, + events: ['pleaseDispose', 'readyToDispose'] + }; + + var g = gm('test').options({ disposers: [ disposer ] }); + assert.deepEqual([disposer], g._options.disposers); + + var sub = gm.subClass({ disposers: [ disposer ]}); + assert.deepEqual([disposer], sub.prototype._options.disposers); + + if (!gm.integration) { + return finish(); + } + + gm(dir + '/photo.JPG').options({ disposers: [ disposer ]}) + .thumb(1000, 1000, dir + '/dispose.png', function (err) { + assert.ok(err, "Expecting a disposed error"); + }); + + emitter.emit('pleaseDispose'); + + noDispose(); + + function noDispose() { + gm(dir + '/photo.JPG').options({ disposers: [ disposer ]}) + .thumb(1000, 1000, dir + '/dispose.png', function (err) { + delete emitter; + delete disposer; + finish(err); + }); + emitter.emit('disposeOK'); + } +} From 18492cc373b6f443f00ce8ae81ac9a7316a7c5a2 Mon Sep 17 00:00:00 2001 From: aeo3 Date: Fri, 12 Feb 2016 12:50:42 +0000 Subject: [PATCH 08/64] Fixing error handling if gm is not installed. --- lib/command.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/command.js b/lib/command.js index 9811f739..0b36589a 100644 --- a/lib/command.js +++ b/lib/command.js @@ -225,6 +225,14 @@ module.exports = function (proto) { return cb(e); } proc.stdin.once('error', cb); + + proc.on('error', function(err){ + if (err.code === 'ENOENT') { + cb(new Error('Could not execute GraphicsMagick/ImageMagick: '+cmd+" this most likely means the gm/convert binaries can't be found")); + } else { + cb(err); + } + }); if (timeout) { timeoutId = setTimeout(function(){ @@ -293,14 +301,6 @@ module.exports = function (proto) { cb(err, stdout, stderr, cmd); stdout = stderr = onOut = onErr = onExit = null; }); - - proc.on('error', function(err){ - if (err.code === 'ENOENT') { - cb(new Error('Could not execute GraphicsMagick/ImageMagick: '+cmd+" this most likely means the gm/convert binaries can't be found")); - } else { - cb(err); - } - }); } else { cb(null, proc.stdout, proc.stderr, cmd); } From 6cd305da48d96e505788b8c4db6df1d4cfb94ab1 Mon Sep 17 00:00:00 2001 From: "N.Ardi" Date: Wed, 16 Mar 2016 14:33:19 +0700 Subject: [PATCH 09/64] Support multiple value while identify image. When metadata has multiple value like keywords parser(./lib/getters.js) just take the last because parser override the previous value. Instead of override this commit cast it to array. --- lib/getters.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/getters.js b/lib/getters.js index 88317c5b..35d26cac 100755 --- a/lib/getters.js +++ b/lib/getters.js @@ -228,7 +228,20 @@ module.exports = function (gm) { level = indent; if (val) { - o[key] = val; + // if previous key was exist and we got the same key + // cast it to an array. + if(o.hasOwnProperty(key)){ + // cast it to an array and dont forget the previous value + if(!Array.isArray(o[key])){ + var tmp = o[key]; + o[key] = [tmp]; + } + + // set value + o[key].push(val); + } else { + o[key] = val; + } if (key in helper) { helper[key](o, val); @@ -330,3 +343,4 @@ module.exports = function (gm) { } }; } + From b4eab5d39583b5622d8f054eb4834434227df994 Mon Sep 17 00:00:00 2001 From: "N.Ardi" Date: Thu, 17 Mar 2016 11:09:44 +0700 Subject: [PATCH 10/64] identify test, get multiple value on metadata --- test/fixtures/iptc-multiple.jpg | Bin 0 -> 19528 bytes test/getterMultipleIptc.js | 31 +++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 test/fixtures/iptc-multiple.jpg create mode 100644 test/getterMultipleIptc.js diff --git a/test/fixtures/iptc-multiple.jpg b/test/fixtures/iptc-multiple.jpg new file mode 100644 index 0000000000000000000000000000000000000000..db25eb84b7dee0b816be398e0b67b9de020c86ec GIT binary patch literal 19528 zcmeHud0bOR*YMng5I}Y!0tN`6kbpoE0t5sM`yxvS;6hyp5J-?U39?v95Vs;C2r8x& zu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+- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/compare.js b/lib/compare.js index bb1151c3..bab52622 100644 --- a/lib/compare.js +++ b/lib/compare.js @@ -42,7 +42,7 @@ module.exports = exports = function (proto) { throw new TypeError('The path for the diff output is invalid'); } // graphicsmagick defaults to red - if (options.highlightColour) { + if (options.highlightColor) { args.push('-highlight-color'); args.push(options.highlightColor); } From c1bef9d4fd21e34ef8138f44a85c342aeae1f174 Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Thu, 7 Apr 2016 10:50:44 -0700 Subject: [PATCH 12/64] release 1.22.0 --- History.md | 8 ++++++++ package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 80584088..2b39c8c1 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,11 @@ + +1.22.0 / 2016-04-07 + + * fixed; identity parser: support multi-value keys by creating an array #508 #509 [emaniacs](https://github.com/emaniacs) + * fixed; error handling if gm is not installed #499 [aeo3](https://github.com/aeo3) + * fixed; highlightColor typo in compare #504 [DanielHudson](https://github.com/DanielHudson) + * docs; Fix typo #475 [rodrigoalviani](https://github.com/rodrigoalviani) + 1.21.1 / 2015-10-26 * fixed: Fixed #465 hard coded gm binary, also fixed issues with compare and fixed tests so they will fail on subsequent runs when they should do [rwky](https://github.com/rwky) diff --git a/package.json b/package.json index 1b7170e8..f6245ecb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "gm", "description": "GraphicsMagick and ImageMagick for node.js", - "version": "1.21.1", + "version": "1.22.0", "author": "Aaron Heckmann ", "keywords": [ "graphics", From d7cf98b191ef01b7ae651d429e6b19e0ebf305d5 Mon Sep 17 00:00:00 2001 From: Sebastian Mayr Date: Fri, 20 May 2016 15:01:43 +0200 Subject: [PATCH 13/64] Make thumbnail accept the same options as resize --- lib/args.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/args.js b/lib/args.js index 5bffdd2f..35089f77 100644 --- a/lib/args.js +++ b/lib/args.js @@ -589,8 +589,25 @@ module.exports = function (proto) { } // http://www.graphicsmagick.org/GraphicsMagick.html#details-thumbnail - proto.thumbnail = function thumbnail (width, height) { - return this.out("-thumbnail", width + "x" + height); + proto.thumbnail = function thumbnail (w, h, options) { + options = options || ""; + var geometry, + wIsValid = Boolean(w || w === 0), + hIsValid = Boolean(h || h === 0); + + if (wIsValid && hIsValid) { + geometry = w + "x" + h + options + } else if (wIsValid) { + // GraphicsMagick requires x, ImageMagick requires + geometry = (this._options.imageMagick) ? w + options : w + + 'x' + options; + } else if (hIsValid) { + geometry = 'x' + h + options + } else { + return this + } + + return this.out("-thumbnail", geometry); } // http://www.graphicsmagick.org/GraphicsMagick.html#details-tile From 2dbb38a49d565ddd0c6bbbc72bdda8d04b15d65a Mon Sep 17 00:00:00 2001 From: Alex Olshansky Date: Mon, 30 May 2016 22:38:10 +0200 Subject: [PATCH 14/64] Fix a link in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bb6be3b1..32fe5ff3 100644 --- a/README.md +++ b/README.md @@ -313,7 +313,7 @@ The links below refer to an older version of gm but everything should still work - getters - [size](http://aheckmann.github.com/gm/docs.html#getters) - returns the size (WxH) of the image - - [orientation](http://aheckmann.github.com/gm/docs.html#orientation) - returns the EXIF orientation of the image + - [orientation](http://aheckmann.github.com/gm/docs.html#getters) - returns the EXIF orientation of the image - [format](http://aheckmann.github.com/gm/docs.html#getters) - returns the image format (gif, jpeg, png, etc) - [depth](http://aheckmann.github.com/gm/docs.html#getters) - returns the image color depth - [color](http://aheckmann.github.com/gm/docs.html#getters) - returns the number of colors From c692f568ab5e6b04177c769a78ea5f8c602d8448 Mon Sep 17 00:00:00 2001 From: Brian Dukes Date: Tue, 7 Jun 2016 16:07:13 -0500 Subject: [PATCH 15/64] Use cross-spawn to spawn processes This provides better cross-platform support --- lib/command.js | 2 +- lib/compare.js | 2 +- package.json | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/command.js b/lib/command.js index 0b36589a..3101922f 100644 --- a/lib/command.js +++ b/lib/command.js @@ -3,7 +3,7 @@ * Module dependencies. */ -var spawn = require('child_process').spawn; +var spawn = require('cross-spawn'); var utils = require('./utils'); var debug = require('debug')('gm'); var series = require('array-series'); diff --git a/lib/compare.js b/lib/compare.js index bab52622..a24ea047 100644 --- a/lib/compare.js +++ b/lib/compare.js @@ -1,6 +1,6 @@ // compare -var spawn = require('child_process').spawn; +var spawn = require('cross-spawn'); /** * Compare two images uses graphicsmagicks `compare` command. diff --git a/package.json b/package.json index f6245ecb..a783464b 100644 --- a/package.json +++ b/package.json @@ -40,8 +40,9 @@ "async": "~0.9.0" }, "dependencies": { - "debug": "~2.2.0", + "array-parallel": "~0.1.3", "array-series": "~0.1.5", - "array-parallel": "~0.1.3" + "cross-spawn": "^4.0.0", + "debug": "~2.2.0" } } From 41aea527cb0f6b6195310af71325ea3c8eb6e6be Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 21 Jun 2016 15:29:56 +0800 Subject: [PATCH 16/64] added example of loading image from URL --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index bb6be3b1..b99c79ec 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,18 @@ gm(readStream, 'img.jpg') if (!err) console.log('done'); }); + +// passing a downloadable image by url + +var request = require('request'); +var url = "www.abc.com/pic.jpg" + +gm(request(url)) +.write('/path/to/reformat.png', function (err) { + if (!err) console.log('done'); +}); + + // can also stream output to a ReadableStream // (can be piped to a local file or remote server) gm('/path/to/my/img.jpg') From 4ee9ddb2c15e3bec561dd9265febd1c335c0a7b8 Mon Sep 17 00:00:00 2001 From: sean shirazi Date: Mon, 27 Jun 2016 19:45:42 +0300 Subject: [PATCH 17/64] works with webpack Trying to read (__dirname + '/package.json') file at run-time won't work with webpack. Using require('./package.json') instead allows webpack to include package.json's source into the bundle. --- index.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/index.js b/index.js index 6e622d8a..8f5f8d54 100644 --- a/index.js +++ b/index.js @@ -126,7 +126,4 @@ require("./lib/montage")(gm.prototype); module.exports = exports = gm; module.exports.utils = require('./lib/utils'); module.exports.compare = require('./lib/compare')(); -module.exports.version = JSON.parse( - require('fs').readFileSync(__dirname + '/package.json', 'utf8') -).version; - +module.exports.version = require('./package.json').version; From 90d4b51852ea070378867d9844d8d1efc0e04416 Mon Sep 17 00:00:00 2001 From: Amila Welihinda Date: Wed, 6 Jul 2016 12:14:13 -0700 Subject: [PATCH 18/64] Added travis ci support for modern node versions --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index f312f797..22b95e97 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,8 @@ before_install: - sudo apt-get install imagemagick graphicsmagick language: node_js node_js: + - "6" + - "4" - "0.10" - "0.12" - "iojs-v2" From d650da6a1ca446c23641dba8d7e98c12e3f3b26c Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Wed, 3 Aug 2016 15:19:46 -0700 Subject: [PATCH 19/64] release 1.23.0 --- History.md | 10 ++++++++++ package.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 2b39c8c1..08173d60 100644 --- a/History.md +++ b/History.md @@ -1,4 +1,14 @@ +1.23.0 / 2016-08-03 + + * fixed; webpack support #547 sean-shirazi + * fixed; windows support - use cross-spawn to spawn processes #537 bdukes + * added; allow thumbnail to accept the same options as resize #527 Sebmaster + * added; dispose support #487 dlwr + * docs; add example of loading image from URL #544 wahengchang + * docs; Fix a link in README.md #532 clbn + * travis; update travis versions #551 amilajack + 1.22.0 / 2016-04-07 * fixed; identity parser: support multi-value keys by creating an array #508 #509 [emaniacs](https://github.com/emaniacs) diff --git a/package.json b/package.json index a783464b..e61c0a27 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "gm", "description": "GraphicsMagick and ImageMagick for node.js", - "version": "1.22.0", + "version": "1.23.0", "author": "Aaron Heckmann ", "keywords": [ "graphics", From 74473c2321829aa7e06e1354a3502263c5cb29a7 Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Wed, 3 Aug 2016 15:38:04 -0700 Subject: [PATCH 20/64] tests; remove global leaks --- test/dispose.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/dispose.js b/test/dispose.js index 585cc742..b2187649 100644 --- a/test/dispose.js +++ b/test/dispose.js @@ -7,9 +7,9 @@ module.exports = function (img, dir, finish, gm) { assert.equal(undefined, gm.prototype._options.disposers); assert.equal(undefined, img._options.disposers); - emitter = new EventEmitter(); + var emitter = new EventEmitter(); - disposer = { + var disposer = { emitter: emitter, events: ['pleaseDispose', 'readyToDispose'] }; @@ -36,8 +36,6 @@ module.exports = function (img, dir, finish, gm) { function noDispose() { gm(dir + '/photo.JPG').options({ disposers: [ disposer ]}) .thumb(1000, 1000, dir + '/dispose.png', function (err) { - delete emitter; - delete disposer; finish(err); }); emitter.emit('disposeOK'); From 46ceadd47035249b92943cd70754c75038333662 Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Thu, 28 Sep 2017 11:35:16 +0200 Subject: [PATCH 21/64] deps: Allow debug@2.6.9 because of security issue --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e61c0a27..c298212e 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,6 @@ "array-parallel": "~0.1.3", "array-series": "~0.1.5", "cross-spawn": "^4.0.0", - "debug": "~2.2.0" + "debug": "^2.2.0" } } From 442d0812935426194f50f0cfcb91931e006704c7 Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Thu, 28 Sep 2017 12:27:33 +0200 Subject: [PATCH 22/64] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c298212e..9e13429c 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,6 @@ "array-parallel": "~0.1.3", "array-series": "~0.1.5", "cross-spawn": "^4.0.0", - "debug": "^2.2.0" + "debug": "^3.1.0" } } From 42d96f25d5bfd0df30bd6e66fa72644ae68a77e5 Mon Sep 17 00:00:00 2001 From: Patryk Miszczak Date: Thu, 9 Nov 2017 13:01:06 +0100 Subject: [PATCH 23/64] Add install graphicsmagick with WebP to README Now GM can support WebP too. --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 18c3c796..462e7925 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,10 @@ First download and install [GraphicsMagick](http://www.graphicsmagick.org/) or [ brew install imagemagick brew install graphicsmagick -If you want WebP support with ImageMagick, you must add the WebP option: +If you want WebP support, you must add the WebP option: brew install imagemagick --with-webp + brew install graphicsmagick --with-webp then either use npm: From 2507d5973aecdee9dd08dc200c048267150accf9 Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Wed, 27 Dec 2017 20:36:56 -0800 Subject: [PATCH 24/64] get tests passing on OSX --- package.json | 1 - test/flatten.js | 8 ++++++-- test/getterIdentify.js | 14 ++++++-------- test/index.js | 7 ------- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index 9e13429c..0cbc9d5e 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,6 @@ }, "license": "MIT", "devDependencies": { - "gleak": "~0.5.0", "async": "~0.9.0" }, "dependencies": { diff --git a/test/flatten.js b/test/flatten.js index 9cdaee86..de5c5332 100644 --- a/test/flatten.js +++ b/test/flatten.js @@ -1,10 +1,14 @@ var assert = require('assert') module.exports = function (img, dir, finish, gm) { - var changed = gm('whatever.png').gravity("Souths") - assert.equal(changed._out[1], 'NorthWest'); + // graphicsmagick considers PSD broken + // http://www.graphicsmagick.org/NEWS.html#may-30-2016 + if (!img._options.imageMagick) { + return finish(); + } var m = gm(dir + '/layers.psd') + .options({ imageMagick: true }) .flatten(); var args = m.args(); diff --git a/test/getterIdentify.js b/test/getterIdentify.js index 9194f18f..6579c535 100755 --- a/test/getterIdentify.js +++ b/test/getterIdentify.js @@ -23,9 +23,9 @@ module.exports = function (_, dir, finish, gm) { assert.equal(d.Orientation, 'TopLeft'); assert.equal(d['Geometry'], '430x488+0+0'); assert.equal(d['Print size'], '5.97222x6.77778'); - assert.equal(d['Channel depth'].red, '8-bit'); - assert.equal(d['Channel depth'].green, '8-bit'); - assert.equal(d['Channel statistics'].Red.min, '0 (0)'); + assert.equal(d['Channel depth'].Red, '8-bit'); + assert.equal(d['Channel depth'].Green, '8-bit'); + assert.equal(d['Channel statistics'].Red.min, '0 (0)'); var sd = d['Channel statistics'].Red['standard deviation'].split(' ') var sd1 = parseFloat(sd[0]) @@ -34,7 +34,7 @@ module.exports = function (_, dir, finish, gm) { assert.ok(sd2 && Math.abs(sd2 - 0.281208) < .001 * errorFactor) var imageStat = parseFloat(d['Image statistics'].Overall.kurtosis) - assert.ok(imageStat && Math.abs(imageStat - -1.09331) < .001 * errorFactor) + assert.ok(imageStat); if (!isLinux) { // This is undefined in Linux @@ -74,10 +74,8 @@ module.exports = function (_, dir, finish, gm) { assert.equal(1, this.data.color); } - var blueWorks = this.data.Colormap['0'] == '( 0, 0,255) #0000FF blue'; - var blackWorks = this.data.Colormap['1'] == '( 0, 0, 0) #000000 black'; - assert.ok(blueWorks); - assert.ok(blackWorks); + assert.ok(/blue/.test(this.data.Colormap['0'])); + assert.ok(/black/.test(this.data.Colormap['1'])); } else { if (!isLinux) { diff --git a/test/index.js b/test/index.js index ebb88856..84c2f89a 100644 --- a/test/index.js +++ b/test/index.js @@ -5,12 +5,7 @@ var async = require('async'); var dir = __dirname + '/../examples/imgs'; var gm = require('../'); var assert = require('assert'); -var gleak = require('gleak')(); var fs = require('fs'); - -gleak.whitelist.push(clearImmediate); -gleak.whitelist.push(setImmediate); - var only = process.argv.slice(2); gm.integration = !! ~process.argv.indexOf('--integration'); if (gm.integration) only.shift(); @@ -63,8 +58,6 @@ q.drain = function(){ process.stdout.write('\033[?25h'); process.stdout.write('\033[2K'); process.stdout.write('\033[0G'); - var leaks = gleak.detect(); - assert.equal(0, leaks.length, "global leaks detected: " + leaks); console.error("\n\u001B[32mAll tests passed\u001B[0m"); }; From e8cfed6e47cd9c0bdf2b4f4a2010502f4fa707d1 Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Wed, 27 Dec 2017 20:44:55 -0800 Subject: [PATCH 25/64] add nsp checks --- Makefile | 9 ++++++--- package.json | 5 +++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index c53cba86..b2ed06c4 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,11 @@ -test: +test: security @node test/ --integration $(TESTS) -test-unit: +test-unit: security @node test/ $(TESTS) -.PHONY: test test-unit +security: + @node_modules/.bin/nsp check + +.PHONY: test test-unit security diff --git a/package.json b/package.json index 0cbc9d5e..1862aad5 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ ], "main": "./index", "scripts": { - "test": "make test-unit; make test;" + "test": "make test;" }, "repository": { "type": "git", @@ -36,7 +36,8 @@ }, "license": "MIT", "devDependencies": { - "async": "~0.9.0" + "async": "~0.9.0", + "nsp": "^3" }, "dependencies": { "array-parallel": "~0.1.3", From 0286f47b1d5c1479c136616a73bced0ee0d2835c Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Wed, 27 Dec 2017 20:48:54 -0800 Subject: [PATCH 26/64] release 1.23.1 --- History.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 08173d60..f9f30769 100644 --- a/History.md +++ b/History.md @@ -1,4 +1,10 @@ +1.23.1 / 2017-12-27 + + * fixed: use debug > 2.6.9 because of security issue #685 danez + * tests; add nsp check + * tests; get tests passing on OSX + 1.23.0 / 2016-08-03 * fixed; webpack support #547 sean-shirazi diff --git a/package.json b/package.json index 1862aad5..aa961bb7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "gm", "description": "GraphicsMagick and ImageMagick for node.js", - "version": "1.23.0", + "version": "1.23.1", "author": "Aaron Heckmann ", "keywords": [ "graphics", From 42c7edffaa2b2800a927784968d637c1653fb450 Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Wed, 27 Dec 2017 21:16:00 -0800 Subject: [PATCH 27/64] fix tests --- package.json | 2 +- test/getterIdentify.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index aa961bb7..964d7e11 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "license": "MIT", "devDependencies": { "async": "~0.9.0", - "nsp": "^3" + "nsp": "^2.8.1" }, "dependencies": { "array-parallel": "~0.1.3", diff --git a/test/getterIdentify.js b/test/getterIdentify.js index 6579c535..571814d5 100755 --- a/test/getterIdentify.js +++ b/test/getterIdentify.js @@ -23,9 +23,9 @@ module.exports = function (_, dir, finish, gm) { assert.equal(d.Orientation, 'TopLeft'); assert.equal(d['Geometry'], '430x488+0+0'); assert.equal(d['Print size'], '5.97222x6.77778'); - assert.equal(d['Channel depth'].Red, '8-bit'); - assert.equal(d['Channel depth'].Green, '8-bit'); - assert.equal(d['Channel statistics'].Red.min, '0 (0)'); + assert.ok(d['Channel depth'].Red || d['Channel depth'].red); + assert.ok(d['Channel depth'].Green || d['Channel depth'].green); + assert.ok(/0\s+\(0\)/.test(d['Channel statistics'].Red.min)); var sd = d['Channel statistics'].Red['standard deviation'].split(' ') var sd1 = parseFloat(sd[0]) From b4db5a1183f0cddcb83ea3c7cdc82da3b868c44d Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Wed, 27 Dec 2017 21:37:54 -0800 Subject: [PATCH 28/64] travis; add node 8 testing --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 22b95e97..9185cd21 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,8 @@ before_install: - sudo apt-get install imagemagick graphicsmagick language: node_js node_js: + - "8" - "6" - "4" - "0.10" - "0.12" - - "iojs-v2" From 4507a02e5bc3c12605456d957493be8c080d0ad6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=99=E8=85=BE=E9=81=93?= Date: Thu, 15 Aug 2019 09:43:08 +0800 Subject: [PATCH 29/64] Update compare.js --- lib/compare.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/compare.js b/lib/compare.js index a24ea047..c39ac490 100644 --- a/lib/compare.js +++ b/lib/compare.js @@ -88,7 +88,6 @@ module.exports = exports = function (proto) { return cb(null, 0 <= tolerance, 0, stdout); } else if (code === 1) { - err = null; stdout = stderr; } else { return cb(stderr); @@ -103,8 +102,7 @@ module.exports = exports = function (proto) { var regex = isImageMagick ? /\((\d+\.?[\d\-\+e]*)\)/m : /Total: (\d+\.?\d*)/m; var match = regex.exec(stdout); if (!match) { - err = new Error('Unable to parse output.\nGot ' + stdout); - return cb(err); + return cb(new Error('Unable to parse output.\nGot ' + stdout)); } var equality = parseFloat(match[1]); From 61de936e55c8ffdb30ceab3959eea04d1e272f14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aar=C3=B3n=20Garc=C3=ADa=20Herv=C3=A1s?= Date: Fri, 6 Mar 2020 15:46:58 +0100 Subject: [PATCH 30/64] Fix README typo --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 18c3c796..9874f51c 100644 --- a/README.md +++ b/README.md @@ -531,7 +531,7 @@ The links below refer to an older version of gm but everything should still work - **stream** - provides a `ReadableStream` with the processed image data - **toBuffer** - returns the image as a `Buffer` instead of a stream -##compare +## compare Graphicsmagicks `compare` command is exposed through `gm.compare()`. This allows us to determine if two images can be considered "equal". @@ -580,7 +580,7 @@ gm.compare('/path/to/image1.jpg', '/path/to/another.png', options, function (err }) ``` -##composite +## 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. @@ -597,7 +597,7 @@ gm('/path/to/image.jpg') }); ``` -##montage +## montage GraphicsMagick supports montage for combining images side by side. This is exposed through `gm.montage()`. Its only argument is an image path with the changes to the base image. From bcca22e1403b3fcf96f793ae0470c0a8a70138a5 Mon Sep 17 00:00:00 2001 From: ash Date: Wed, 24 Feb 2021 16:02:26 -0500 Subject: [PATCH 31/64] add test for noncompliant pdfs erroring out --- test/fixtures/synthetic_invalid.pdf | Bin 0 -> 8536 bytes test/pdf-noncompliant.js | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 test/fixtures/synthetic_invalid.pdf create mode 100644 test/pdf-noncompliant.js diff --git a/test/fixtures/synthetic_invalid.pdf b/test/fixtures/synthetic_invalid.pdf new file mode 100644 index 0000000000000000000000000000000000000000..acdab0c8d2e1a275b337e81a523a6bf77e39b722 GIT binary patch literal 8536 zcmaiZ1z1#D+qOz6NDC-ANJ`BxFhNLncQ*_TgD^CRNJ&e#7<7YlNjK7+N(m?>O3Odv zIp;m+{m%DY|DJ2j-uqckuY0YzuDMy%q-3~xd7y+WojIM&owc3WgkS&&fV8kD6cz?5 zA)IYcwg5h~L<1;e=ZHeM0%aV{Q3xr7CDIBZB7*ORaz&Us5qf2^L_Q|y5F?SgxS}v5 z5U`n9q@u->u{5WGSC9z3%QB&C-W zLed#F6fEC_v;M-WrhX`ek8rm7Gad93x&nNBOyZaaUOq5p_O}f3r|j?Yp#MjCf0oY+ z;N=B@LH{gvL%`RCW+Q6_sS7kruBj>wdnadrSZj9FuiXfSGavR4&xL2{#W-=Kkto($ zDVixpCQSvh{pP-^h@k?LutEi!_ zU%PMirAV&{8P6RBlZK`HjU$6gme{^er0F$Yj~!BxUSl(Uy_0kESD!4-bLs~+dPxTF zrjn9&IqxQ|U$49oQ5nk7ZHc}wpKbyan$^rn7MAGyoB^)&8$JQHo&-DyDRa5FdqyT8 z8IzD5PjfFc8(Z!5mUT0H|0``qGSk+Z+8St z@xJ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9KV)z?dPV+Q1_Sf`OAp2m`Bw}W zKOBv)|6vRJU;M#g=neRn9?I1meVn^uK&ffxgFv?msDVVHQHA!8*|qY{)=0qbRmZ$Y z0Sp1c{CqID1Qa3wg788Fc%@+ie3CMJGSa+oxFnPxj9K&lzX}GvQb Date: Wed, 24 Feb 2021 16:43:47 -0500 Subject: [PATCH 32/64] attribute bug 820 --- test/pdf-noncompliant.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/pdf-noncompliant.js b/test/pdf-noncompliant.js index 9e1816d3..72ee34c1 100644 --- a/test/pdf-noncompliant.js +++ b/test/pdf-noncompliant.js @@ -1,5 +1,6 @@ 'use strict'; +//https://github.com/aheckmann/gm/issues/820 var assert = require('assert'); var fs = require('fs'); var path = require('path'); From 5f536c2464c2f680cd0fd49ffa350d291130ac39 Mon Sep 17 00:00:00 2001 From: ash Date: Mon, 8 Mar 2021 10:27:38 -0500 Subject: [PATCH 33/64] filter out errors from noncompliant pdfs, allow gm to operate on them see issues/820 --- README.md | 3 +++ lib/command.js | 6 +++++- lib/nuisanceConsumer.js | 10 ++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 lib/nuisanceConsumer.js diff --git a/README.md b/README.md index 18c3c796..b6096897 100644 --- a/README.md +++ b/README.md @@ -623,6 +623,9 @@ http://github.com/quiiver/magickal-node ## Plugins [https://github.com/aheckmann/gm/wiki](https://github.com/aheckmann/gm/wiki) +## Tests +node test --integration --only pdf-noncompliant.js + ## License (The MIT License) diff --git a/lib/command.js b/lib/command.js index 2ff464fe..0c55d142 100644 --- a/lib/command.js +++ b/lib/command.js @@ -8,6 +8,7 @@ var utils = require('./utils'); var debug = require('debug')('gm'); var series = require('array-series'); var PassThrough = require('stream').PassThrough; +var nuisanceConsumer = require('./nuisanceConsumer'); /** * Error messaging. @@ -289,7 +290,10 @@ module.exports = function (proto) { , onExit proc.stdout.on('data', onOut = function (data) { - stdout += data; + if ( nuisanceConsumer.isNuisance( data ) == 1 ) + { /*console.log("elided", data); */ stderr+= data; } + else + {stdout += data;} }); proc.stderr.on('data', onErr = function (data) { diff --git a/lib/nuisanceConsumer.js b/lib/nuisanceConsumer.js new file mode 100644 index 00000000..df848807 --- /dev/null +++ b/lib/nuisanceConsumer.js @@ -0,0 +1,10 @@ +//issues/820 + +module.exports = exports = {}; +exports.isNuisance = function(instring) { + //console.log ("wat", instring.toString(), typeof(instring)); + // scan each emitted line, if it's an error line, remove it +//**** Error: stream operator isn't terminated by valid EOL. + if( instring.toString().indexOf ("**** Error: stream operator isn't terminated by valid EOL.") > 1) { return 1 } + return 0 ; +} From 2f3df66512f8bad7af5ea0976c60aea67be23a2d Mon Sep 17 00:00:00 2001 From: Andrew Lessels Date: Sat, 12 Jun 2021 14:34:06 +1000 Subject: [PATCH 34/64] Fix docs links --- README.md | 394 +++++++++++++++++++++++++++--------------------------- 1 file changed, 197 insertions(+), 197 deletions(-) diff --git a/README.md b/README.md index 18c3c796..6027d415 100644 --- a/README.md +++ b/README.md @@ -324,207 +324,207 @@ The links below refer to an older version of gm but everything should still work ## Methods - getters - - [size](http://aheckmann.github.com/gm/docs.html#getters) - returns the size (WxH) of the image - - [orientation](http://aheckmann.github.com/gm/docs.html#getters) - returns the EXIF orientation of the image - - [format](http://aheckmann.github.com/gm/docs.html#getters) - returns the image format (gif, jpeg, png, etc) - - [depth](http://aheckmann.github.com/gm/docs.html#getters) - returns the image color depth - - [color](http://aheckmann.github.com/gm/docs.html#getters) - returns the number of colors - - [res](http://aheckmann.github.com/gm/docs.html#getters) - returns the image resolution - - [filesize](http://aheckmann.github.com/gm/docs.html#getters) - returns image filesize - - [identify](http://aheckmann.github.com/gm/docs.html#getters) - returns all image data available. Takes an optional format string. + - [size](http://aheckmann.github.io/gm/docs.html#getters) - returns the size (WxH) of the image + - [orientation](http://aheckmann.github.io/gm/docs.html#getters) - returns the EXIF orientation of the image + - [format](http://aheckmann.github.io/gm/docs.html#getters) - returns the image format (gif, jpeg, png, etc) + - [depth](http://aheckmann.github.io/gm/docs.html#getters) - returns the image color depth + - [color](http://aheckmann.github.io/gm/docs.html#getters) - returns the number of colors + - [res](http://aheckmann.github.io/gm/docs.html#getters) - returns the image resolution + - [filesize](http://aheckmann.github.io/gm/docs.html#getters) - returns image filesize + - [identify](http://aheckmann.github.io/gm/docs.html#getters) - returns all image data available. Takes an optional format string. - manipulation - - [adjoin](http://aheckmann.github.com/gm/docs.html#adjoin) - - [affine](http://aheckmann.github.com/gm/docs.html#affine) - - [antialias](http://aheckmann.github.com/gm/docs.html#antialias) - - [append](http://aheckmann.github.com/gm/docs.html#append) - - [authenticate](http://aheckmann.github.com/gm/docs.html#authenticate) - - [autoOrient](http://aheckmann.github.com/gm/docs.html#autoOrient) - - [average](http://aheckmann.github.com/gm/docs.html#average) - - [backdrop](http://aheckmann.github.com/gm/docs.html#backdrop) - - [bitdepth](http://aheckmann.github.com/gm/docs.html#bitdepth) - - [blackThreshold](http://aheckmann.github.com/gm/docs.html#blackThreshold) - - [bluePrimary](http://aheckmann.github.com/gm/docs.html#bluePrimary) - - [blur](http://aheckmann.github.com/gm/docs.html#blur) - - [border](http://aheckmann.github.com/gm/docs.html#border) - - [borderColor](http://aheckmann.github.com/gm/docs.html#borderColor) - - [box](http://aheckmann.github.com/gm/docs.html#box) - - [channel](http://aheckmann.github.com/gm/docs.html#channel) - - [charcoal](http://aheckmann.github.com/gm/docs.html#charcoal) - - [chop](http://aheckmann.github.com/gm/docs.html#chop) - - [clip](http://aheckmann.github.com/gm/docs.html#clip) - - [coalesce](http://aheckmann.github.com/gm/docs.html#coalesce) - - [colors](http://aheckmann.github.com/gm/docs.html#colors) - - [colorize](http://aheckmann.github.com/gm/docs.html#colorize) - - [colorMap](http://aheckmann.github.com/gm/docs.html#colorMap) - - [colorspace](http://aheckmann.github.com/gm/docs.html#colorspace) - - [comment](http://aheckmann.github.com/gm/docs.html#comment) - - [compose](http://aheckmann.github.com/gm/docs.html#compose) - - [compress](http://aheckmann.github.com/gm/docs.html#compress) - - [contrast](http://aheckmann.github.com/gm/docs.html#contrast) - - [convolve](http://aheckmann.github.com/gm/docs.html#convolve) - - [createDirectories](http://aheckmann.github.com/gm/docs.html#createDirectories) - - [crop](http://aheckmann.github.com/gm/docs.html#crop) - - [cycle](http://aheckmann.github.com/gm/docs.html#cycle) - - [deconstruct](http://aheckmann.github.com/gm/docs.html#deconstruct) - - [delay](http://aheckmann.github.com/gm/docs.html#delay) - - [define](http://aheckmann.github.com/gm/docs.html#define) - - [density](http://aheckmann.github.com/gm/docs.html#density) - - [despeckle](http://aheckmann.github.com/gm/docs.html#despeckle) - - [dither](http://aheckmann.github.com/gm/docs.html#dither) - - [displace](http://aheckmann.github.com/gm/docs.html#dither) - - [display](http://aheckmann.github.com/gm/docs.html#display) - - [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) - - [emboss](http://aheckmann.github.com/gm/docs.html#emboss) - - [encoding](http://aheckmann.github.com/gm/docs.html#encoding) - - [enhance](http://aheckmann.github.com/gm/docs.html#enhance) - - [endian](http://aheckmann.github.com/gm/docs.html#endian) - - [equalize](http://aheckmann.github.com/gm/docs.html#equalize) - - [extent](http://aheckmann.github.com/gm/docs.html#extent) - - [file](http://aheckmann.github.com/gm/docs.html#file) - - [filter](http://aheckmann.github.com/gm/docs.html#filter) - - [flatten](http://aheckmann.github.com/gm/docs.html#flatten) - - [flip](http://aheckmann.github.com/gm/docs.html#flip) - - [flop](http://aheckmann.github.com/gm/docs.html#flop) - - [foreground](http://aheckmann.github.com/gm/docs.html#foreground) - - [frame](http://aheckmann.github.com/gm/docs.html#frame) - - [fuzz](http://aheckmann.github.com/gm/docs.html#fuzz) - - [gamma](http://aheckmann.github.com/gm/docs.html#gamma) - - [gaussian](http://aheckmann.github.com/gm/docs.html#gaussian) - - [geometry](http://aheckmann.github.com/gm/docs.html#geometry) - - [gravity](http://aheckmann.github.com/gm/docs.html#gravity) - - [greenPrimary](http://aheckmann.github.com/gm/docs.html#greenPrimary) - - [highlightColor](http://aheckmann.github.com/gm/docs.html#highlightColor) - - [highlightStyle](http://aheckmann.github.com/gm/docs.html#highlightStyle) - - [iconGeometry](http://aheckmann.github.com/gm/docs.html#iconGeometry) - - [implode](http://aheckmann.github.com/gm/docs.html#implode) - - [intent](http://aheckmann.github.com/gm/docs.html#intent) - - [interlace](http://aheckmann.github.com/gm/docs.html#interlace) - - [label](http://aheckmann.github.com/gm/docs.html#label) - - [lat](http://aheckmann.github.com/gm/docs.html#lat) - - [level](http://aheckmann.github.com/gm/docs.html#level) - - [list](http://aheckmann.github.com/gm/docs.html#list) - - [limit](http://aheckmann.github.com/gm/docs.html#limit) - - [log](http://aheckmann.github.com/gm/docs.html#log) - - [loop](http://aheckmann.github.com/gm/docs.html#loop) - - [lower](http://aheckmann.github.com/gm/docs.html#lower) - - [magnify](http://aheckmann.github.com/gm/docs.html#magnify) - - [map](http://aheckmann.github.com/gm/docs.html#map) - - [matte](http://aheckmann.github.com/gm/docs.html#matte) - - [matteColor](http://aheckmann.github.com/gm/docs.html#matteColor) - - [mask](http://aheckmann.github.com/gm/docs.html#mask) - - [maximumError](http://aheckmann.github.com/gm/docs.html#maximumError) - - [median](http://aheckmann.github.com/gm/docs.html#median) - - [minify](http://aheckmann.github.com/gm/docs.html#minify) - - [mode](http://aheckmann.github.com/gm/docs.html#mode) - - [modulate](http://aheckmann.github.com/gm/docs.html#modulate) - - [monitor](http://aheckmann.github.com/gm/docs.html#monitor) - - [monochrome](http://aheckmann.github.com/gm/docs.html#monochrome) - - [morph](http://aheckmann.github.com/gm/docs.html#morph) - - [mosaic](http://aheckmann.github.com/gm/docs.html#mosaic) - - [motionBlur](http://aheckmann.github.com/gm/docs.html#motionBlur) - - [name](http://aheckmann.github.com/gm/docs.html#name) - - [negative](http://aheckmann.github.com/gm/docs.html#negative) - - [noise](http://aheckmann.github.com/gm/docs.html#noise) - - [noop](http://aheckmann.github.com/gm/docs.html#noop) - - [normalize](http://aheckmann.github.com/gm/docs.html#normalize) - - [noProfile](http://aheckmann.github.com/gm/docs.html#profile) - - [opaque](http://aheckmann.github.com/gm/docs.html#opaque) - - [operator](http://aheckmann.github.com/gm/docs.html#operator) - - [orderedDither](http://aheckmann.github.com/gm/docs.html#orderedDither) - - [outputDirectory](http://aheckmann.github.com/gm/docs.html#outputDirectory) - - [paint](http://aheckmann.github.com/gm/docs.html#paint) - - [page](http://aheckmann.github.com/gm/docs.html#page) - - [pause](http://aheckmann.github.com/gm/docs.html#pause) - - [pen](http://aheckmann.github.com/gm/docs.html#pen) - - [ping](http://aheckmann.github.com/gm/docs.html#ping) - - [pointSize](http://aheckmann.github.com/gm/docs.html#pointSize) - - [preview](http://aheckmann.github.com/gm/docs.html#preview) - - [process](http://aheckmann.github.com/gm/docs.html#process) - - [profile](http://aheckmann.github.com/gm/docs.html#profile) - - [progress](http://aheckmann.github.com/gm/docs.html#progress) - - [quality](http://aheckmann.github.com/gm/docs.html#quality) - - [raise](http://aheckmann.github.com/gm/docs.html#raise) - - [rawSize](http://aheckmann.github.com/gm/docs.html#rawSize) - - [randomThreshold](http://aheckmann.github.com/gm/docs.html#randomThreshold) - - [recolor](http://aheckmann.github.com/gm/docs.html#recolor) - - [redPrimary](http://aheckmann.github.com/gm/docs.html#redPrimary) - - [region](http://aheckmann.github.com/gm/docs.html#region) - - [remote](http://aheckmann.github.com/gm/docs.html#remote) - - [render](http://aheckmann.github.com/gm/docs.html#render) - - [repage](http://aheckmann.github.com/gm/docs.html#repage) - - [resample](http://aheckmann.github.com/gm/docs.html#resample) - - [resize](http://aheckmann.github.com/gm/docs.html#resize) - - [roll](http://aheckmann.github.com/gm/docs.html#roll) - - [rotate](http://aheckmann.github.com/gm/docs.html#rotate) - - [sample](http://aheckmann.github.com/gm/docs.html#sample) - - [samplingFactor](http://aheckmann.github.com/gm/docs.html#samplingFactor) - - [scale](http://aheckmann.github.com/gm/docs.html#scale) - - [scene](http://aheckmann.github.com/gm/docs.html#scene) - - [scenes](http://aheckmann.github.com/gm/docs.html#scenes) - - [screen](http://aheckmann.github.com/gm/docs.html#screen) - - [segment](http://aheckmann.github.com/gm/docs.html#segment) - - [sepia](http://aheckmann.github.com/gm/docs.html#sepia) - - [set](http://aheckmann.github.com/gm/docs.html#set) - - [setFormat](http://aheckmann.github.com/gm/docs.html#setformat) - - [shade](http://aheckmann.github.com/gm/docs.html#shade) - - [shadow](http://aheckmann.github.com/gm/docs.html#shadow) - - [sharedMemory](http://aheckmann.github.com/gm/docs.html#sharedMemory) - - [sharpen](http://aheckmann.github.com/gm/docs.html#sharpen) - - [shave](http://aheckmann.github.com/gm/docs.html#shave) - - [shear](http://aheckmann.github.com/gm/docs.html#shear) - - [silent](http://aheckmann.github.com/gm/docs.html#silent) - - [solarize](http://aheckmann.github.com/gm/docs.html#solarize) - - [snaps](http://aheckmann.github.com/gm/docs.html#snaps) - - [stegano](http://aheckmann.github.com/gm/docs.html#stegano) - - [stereo](http://aheckmann.github.com/gm/docs.html#stereo) - - [strip](http://aheckmann.github.com/gm/docs.html#strip) _imagemagick only_ - - [spread](http://aheckmann.github.com/gm/docs.html#spread) - - [swirl](http://aheckmann.github.com/gm/docs.html#swirl) - - [textFont](http://aheckmann.github.com/gm/docs.html#textFont) - - [texture](http://aheckmann.github.com/gm/docs.html#texture) - - [threshold](http://aheckmann.github.com/gm/docs.html#threshold) - - [thumb](http://aheckmann.github.com/gm/docs.html#thumb) - - [tile](http://aheckmann.github.com/gm/docs.html#tile) - - [transform](http://aheckmann.github.com/gm/docs.html#transform) - - [transparent](http://aheckmann.github.com/gm/docs.html#transparent) - - [treeDepth](http://aheckmann.github.com/gm/docs.html#treeDepth) - - [trim](http://aheckmann.github.com/gm/docs.html#trim) - - [type](http://aheckmann.github.com/gm/docs.html#type) - - [update](http://aheckmann.github.com/gm/docs.html#update) - - [units](http://aheckmann.github.com/gm/docs.html#units) - - [unsharp](http://aheckmann.github.com/gm/docs.html#unsharp) - - [usePixmap](http://aheckmann.github.com/gm/docs.html#usePixmap) - - [view](http://aheckmann.github.com/gm/docs.html#view) - - [virtualPixel](http://aheckmann.github.com/gm/docs.html#virtualPixel) - - [visual](http://aheckmann.github.com/gm/docs.html#visual) - - [watermark](http://aheckmann.github.com/gm/docs.html#watermark) - - [wave](http://aheckmann.github.com/gm/docs.html#wave) - - [whitePoint](http://aheckmann.github.com/gm/docs.html#whitePoint) - - [whiteThreshold](http://aheckmann.github.com/gm/docs.html#whiteThreshold) - - [window](http://aheckmann.github.com/gm/docs.html#window) - - [windowGroup](http://aheckmann.github.com/gm/docs.html#windowGroup) + - [adjoin](http://aheckmann.github.io/gm/docs.html#adjoin) + - [affine](http://aheckmann.github.io/gm/docs.html#affine) + - [antialias](http://aheckmann.github.io/gm/docs.html#antialias) + - [append](http://aheckmann.github.io/gm/docs.html#append) + - [authenticate](http://aheckmann.github.io/gm/docs.html#authenticate) + - [autoOrient](http://aheckmann.github.io/gm/docs.html#autoOrient) + - [average](http://aheckmann.github.io/gm/docs.html#average) + - [backdrop](http://aheckmann.github.io/gm/docs.html#backdrop) + - [bitdepth](http://aheckmann.github.io/gm/docs.html#bitdepth) + - [blackThreshold](http://aheckmann.github.io/gm/docs.html#blackThreshold) + - [bluePrimary](http://aheckmann.github.io/gm/docs.html#bluePrimary) + - [blur](http://aheckmann.github.io/gm/docs.html#blur) + - [border](http://aheckmann.github.io/gm/docs.html#border) + - [borderColor](http://aheckmann.github.io/gm/docs.html#borderColor) + - [box](http://aheckmann.github.io/gm/docs.html#box) + - [channel](http://aheckmann.github.io/gm/docs.html#channel) + - [charcoal](http://aheckmann.github.io/gm/docs.html#charcoal) + - [chop](http://aheckmann.github.io/gm/docs.html#chop) + - [clip](http://aheckmann.github.io/gm/docs.html#clip) + - [coalesce](http://aheckmann.github.io/gm/docs.html#coalesce) + - [colors](http://aheckmann.github.io/gm/docs.html#colors) + - [colorize](http://aheckmann.github.io/gm/docs.html#colorize) + - [colorMap](http://aheckmann.github.io/gm/docs.html#colorMap) + - [colorspace](http://aheckmann.github.io/gm/docs.html#colorspace) + - [comment](http://aheckmann.github.io/gm/docs.html#comment) + - [compose](http://aheckmann.github.io/gm/docs.html#compose) + - [compress](http://aheckmann.github.io/gm/docs.html#compress) + - [contrast](http://aheckmann.github.io/gm/docs.html#contrast) + - [convolve](http://aheckmann.github.io/gm/docs.html#convolve) + - [createDirectories](http://aheckmann.github.io/gm/docs.html#createDirectories) + - [crop](http://aheckmann.github.io/gm/docs.html#crop) + - [cycle](http://aheckmann.github.io/gm/docs.html#cycle) + - [deconstruct](http://aheckmann.github.io/gm/docs.html#deconstruct) + - [delay](http://aheckmann.github.io/gm/docs.html#delay) + - [define](http://aheckmann.github.io/gm/docs.html#define) + - [density](http://aheckmann.github.io/gm/docs.html#density) + - [despeckle](http://aheckmann.github.io/gm/docs.html#despeckle) + - [dither](http://aheckmann.github.io/gm/docs.html#dither) + - [displace](http://aheckmann.github.io/gm/docs.html#dither) + - [display](http://aheckmann.github.io/gm/docs.html#display) + - [dispose](http://aheckmann.github.io/gm/docs.html#dispose) + - [dissolve](http://aheckmann.github.io/gm/docs.html#dissolve) + - [edge](http://aheckmann.github.io/gm/docs.html#edge) + - [emboss](http://aheckmann.github.io/gm/docs.html#emboss) + - [encoding](http://aheckmann.github.io/gm/docs.html#encoding) + - [enhance](http://aheckmann.github.io/gm/docs.html#enhance) + - [endian](http://aheckmann.github.io/gm/docs.html#endian) + - [equalize](http://aheckmann.github.io/gm/docs.html#equalize) + - [extent](http://aheckmann.github.io/gm/docs.html#extent) + - [file](http://aheckmann.github.io/gm/docs.html#file) + - [filter](http://aheckmann.github.io/gm/docs.html#filter) + - [flatten](http://aheckmann.github.io/gm/docs.html#flatten) + - [flip](http://aheckmann.github.io/gm/docs.html#flip) + - [flop](http://aheckmann.github.io/gm/docs.html#flop) + - [foreground](http://aheckmann.github.io/gm/docs.html#foreground) + - [frame](http://aheckmann.github.io/gm/docs.html#frame) + - [fuzz](http://aheckmann.github.io/gm/docs.html#fuzz) + - [gamma](http://aheckmann.github.io/gm/docs.html#gamma) + - [gaussian](http://aheckmann.github.io/gm/docs.html#gaussian) + - [geometry](http://aheckmann.github.io/gm/docs.html#geometry) + - [gravity](http://aheckmann.github.io/gm/docs.html#gravity) + - [greenPrimary](http://aheckmann.github.io/gm/docs.html#greenPrimary) + - [highlightColor](http://aheckmann.github.io/gm/docs.html#highlightColor) + - [highlightStyle](http://aheckmann.github.io/gm/docs.html#highlightStyle) + - [iconGeometry](http://aheckmann.github.io/gm/docs.html#iconGeometry) + - [implode](http://aheckmann.github.io/gm/docs.html#implode) + - [intent](http://aheckmann.github.io/gm/docs.html#intent) + - [interlace](http://aheckmann.github.io/gm/docs.html#interlace) + - [label](http://aheckmann.github.io/gm/docs.html#label) + - [lat](http://aheckmann.github.io/gm/docs.html#lat) + - [level](http://aheckmann.github.io/gm/docs.html#level) + - [list](http://aheckmann.github.io/gm/docs.html#list) + - [limit](http://aheckmann.github.io/gm/docs.html#limit) + - [log](http://aheckmann.github.io/gm/docs.html#log) + - [loop](http://aheckmann.github.io/gm/docs.html#loop) + - [lower](http://aheckmann.github.io/gm/docs.html#lower) + - [magnify](http://aheckmann.github.io/gm/docs.html#magnify) + - [map](http://aheckmann.github.io/gm/docs.html#map) + - [matte](http://aheckmann.github.io/gm/docs.html#matte) + - [matteColor](http://aheckmann.github.io/gm/docs.html#matteColor) + - [mask](http://aheckmann.github.io/gm/docs.html#mask) + - [maximumError](http://aheckmann.github.io/gm/docs.html#maximumError) + - [median](http://aheckmann.github.io/gm/docs.html#median) + - [minify](http://aheckmann.github.io/gm/docs.html#minify) + - [mode](http://aheckmann.github.io/gm/docs.html#mode) + - [modulate](http://aheckmann.github.io/gm/docs.html#modulate) + - [monitor](http://aheckmann.github.io/gm/docs.html#monitor) + - [monochrome](http://aheckmann.github.io/gm/docs.html#monochrome) + - [morph](http://aheckmann.github.io/gm/docs.html#morph) + - [mosaic](http://aheckmann.github.io/gm/docs.html#mosaic) + - [motionBlur](http://aheckmann.github.io/gm/docs.html#motionBlur) + - [name](http://aheckmann.github.io/gm/docs.html#name) + - [negative](http://aheckmann.github.io/gm/docs.html#negative) + - [noise](http://aheckmann.github.io/gm/docs.html#noise) + - [noop](http://aheckmann.github.io/gm/docs.html#noop) + - [normalize](http://aheckmann.github.io/gm/docs.html#normalize) + - [noProfile](http://aheckmann.github.io/gm/docs.html#profile) + - [opaque](http://aheckmann.github.io/gm/docs.html#opaque) + - [operator](http://aheckmann.github.io/gm/docs.html#operator) + - [orderedDither](http://aheckmann.github.io/gm/docs.html#orderedDither) + - [outputDirectory](http://aheckmann.github.io/gm/docs.html#outputDirectory) + - [paint](http://aheckmann.github.io/gm/docs.html#paint) + - [page](http://aheckmann.github.io/gm/docs.html#page) + - [pause](http://aheckmann.github.io/gm/docs.html#pause) + - [pen](http://aheckmann.github.io/gm/docs.html#pen) + - [ping](http://aheckmann.github.io/gm/docs.html#ping) + - [pointSize](http://aheckmann.github.io/gm/docs.html#pointSize) + - [preview](http://aheckmann.github.io/gm/docs.html#preview) + - [process](http://aheckmann.github.io/gm/docs.html#process) + - [profile](http://aheckmann.github.io/gm/docs.html#profile) + - [progress](http://aheckmann.github.io/gm/docs.html#progress) + - [quality](http://aheckmann.github.io/gm/docs.html#quality) + - [raise](http://aheckmann.github.io/gm/docs.html#raise) + - [rawSize](http://aheckmann.github.io/gm/docs.html#rawSize) + - [randomThreshold](http://aheckmann.github.io/gm/docs.html#randomThreshold) + - [recolor](http://aheckmann.github.io/gm/docs.html#recolor) + - [redPrimary](http://aheckmann.github.io/gm/docs.html#redPrimary) + - [region](http://aheckmann.github.io/gm/docs.html#region) + - [remote](http://aheckmann.github.io/gm/docs.html#remote) + - [render](http://aheckmann.github.io/gm/docs.html#render) + - [repage](http://aheckmann.github.io/gm/docs.html#repage) + - [resample](http://aheckmann.github.io/gm/docs.html#resample) + - [resize](http://aheckmann.github.io/gm/docs.html#resize) + - [roll](http://aheckmann.github.io/gm/docs.html#roll) + - [rotate](http://aheckmann.github.io/gm/docs.html#rotate) + - [sample](http://aheckmann.github.io/gm/docs.html#sample) + - [samplingFactor](http://aheckmann.github.io/gm/docs.html#samplingFactor) + - [scale](http://aheckmann.github.io/gm/docs.html#scale) + - [scene](http://aheckmann.github.io/gm/docs.html#scene) + - [scenes](http://aheckmann.github.io/gm/docs.html#scenes) + - [screen](http://aheckmann.github.io/gm/docs.html#screen) + - [segment](http://aheckmann.github.io/gm/docs.html#segment) + - [sepia](http://aheckmann.github.io/gm/docs.html#sepia) + - [set](http://aheckmann.github.io/gm/docs.html#set) + - [setFormat](http://aheckmann.github.io/gm/docs.html#setformat) + - [shade](http://aheckmann.github.io/gm/docs.html#shade) + - [shadow](http://aheckmann.github.io/gm/docs.html#shadow) + - [sharedMemory](http://aheckmann.github.io/gm/docs.html#sharedMemory) + - [sharpen](http://aheckmann.github.io/gm/docs.html#sharpen) + - [shave](http://aheckmann.github.io/gm/docs.html#shave) + - [shear](http://aheckmann.github.io/gm/docs.html#shear) + - [silent](http://aheckmann.github.io/gm/docs.html#silent) + - [solarize](http://aheckmann.github.io/gm/docs.html#solarize) + - [snaps](http://aheckmann.github.io/gm/docs.html#snaps) + - [stegano](http://aheckmann.github.io/gm/docs.html#stegano) + - [stereo](http://aheckmann.github.io/gm/docs.html#stereo) + - [strip](http://aheckmann.github.io/gm/docs.html#strip) _imagemagick only_ + - [spread](http://aheckmann.github.io/gm/docs.html#spread) + - [swirl](http://aheckmann.github.io/gm/docs.html#swirl) + - [textFont](http://aheckmann.github.io/gm/docs.html#textFont) + - [texture](http://aheckmann.github.io/gm/docs.html#texture) + - [threshold](http://aheckmann.github.io/gm/docs.html#threshold) + - [thumb](http://aheckmann.github.io/gm/docs.html#thumb) + - [tile](http://aheckmann.github.io/gm/docs.html#tile) + - [transform](http://aheckmann.github.io/gm/docs.html#transform) + - [transparent](http://aheckmann.github.io/gm/docs.html#transparent) + - [treeDepth](http://aheckmann.github.io/gm/docs.html#treeDepth) + - [trim](http://aheckmann.github.io/gm/docs.html#trim) + - [type](http://aheckmann.github.io/gm/docs.html#type) + - [update](http://aheckmann.github.io/gm/docs.html#update) + - [units](http://aheckmann.github.io/gm/docs.html#units) + - [unsharp](http://aheckmann.github.io/gm/docs.html#unsharp) + - [usePixmap](http://aheckmann.github.io/gm/docs.html#usePixmap) + - [view](http://aheckmann.github.io/gm/docs.html#view) + - [virtualPixel](http://aheckmann.github.io/gm/docs.html#virtualPixel) + - [visual](http://aheckmann.github.io/gm/docs.html#visual) + - [watermark](http://aheckmann.github.io/gm/docs.html#watermark) + - [wave](http://aheckmann.github.io/gm/docs.html#wave) + - [whitePoint](http://aheckmann.github.io/gm/docs.html#whitePoint) + - [whiteThreshold](http://aheckmann.github.io/gm/docs.html#whiteThreshold) + - [window](http://aheckmann.github.io/gm/docs.html#window) + - [windowGroup](http://aheckmann.github.io/gm/docs.html#windowGroup) - drawing primitives - - [draw](http://aheckmann.github.com/gm/docs.html#draw) - - [drawArc](http://aheckmann.github.com/gm/docs.html#drawArc) - - [drawBezier](http://aheckmann.github.com/gm/docs.html#drawBezier) - - [drawCircle](http://aheckmann.github.com/gm/docs.html#drawCircle) - - [drawEllipse](http://aheckmann.github.com/gm/docs.html#drawEllipse) - - [drawLine](http://aheckmann.github.com/gm/docs.html#drawLine) - - [drawPoint](http://aheckmann.github.com/gm/docs.html#drawPoint) - - [drawPolygon](http://aheckmann.github.com/gm/docs.html#drawPolygon) - - [drawPolyline](http://aheckmann.github.com/gm/docs.html#drawPolyline) - - [drawRectangle](http://aheckmann.github.com/gm/docs.html#drawRectangle) - - [drawText](http://aheckmann.github.com/gm/docs.html#drawText) - - [fill](http://aheckmann.github.com/gm/docs.html#fill) - - [font](http://aheckmann.github.com/gm/docs.html#font) - - [fontSize](http://aheckmann.github.com/gm/docs.html#fontSize) - - [stroke](http://aheckmann.github.com/gm/docs.html#stroke) - - [strokeWidth](http://aheckmann.github.com/gm/docs.html#strokeWidth) - - [setDraw](http://aheckmann.github.com/gm/docs.html#setDraw) + - [draw](http://aheckmann.github.io/gm/docs.html#draw) + - [drawArc](http://aheckmann.github.io/gm/docs.html#drawArc) + - [drawBezier](http://aheckmann.github.io/gm/docs.html#drawBezier) + - [drawCircle](http://aheckmann.github.io/gm/docs.html#drawCircle) + - [drawEllipse](http://aheckmann.github.io/gm/docs.html#drawEllipse) + - [drawLine](http://aheckmann.github.io/gm/docs.html#drawLine) + - [drawPoint](http://aheckmann.github.io/gm/docs.html#drawPoint) + - [drawPolygon](http://aheckmann.github.io/gm/docs.html#drawPolygon) + - [drawPolyline](http://aheckmann.github.io/gm/docs.html#drawPolyline) + - [drawRectangle](http://aheckmann.github.io/gm/docs.html#drawRectangle) + - [drawText](http://aheckmann.github.io/gm/docs.html#drawText) + - [fill](http://aheckmann.github.io/gm/docs.html#fill) + - [font](http://aheckmann.github.io/gm/docs.html#font) + - [fontSize](http://aheckmann.github.io/gm/docs.html#fontSize) + - [stroke](http://aheckmann.github.io/gm/docs.html#stroke) + - [strokeWidth](http://aheckmann.github.io/gm/docs.html#strokeWidth) + - [setDraw](http://aheckmann.github.io/gm/docs.html#setDraw) - image output - **write** - writes the processed image data to the specified filename From f3e04084e2cefda00518f2697da5bab0cdbe4a24 Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Sun, 11 Sep 2022 08:17:35 -0700 Subject: [PATCH 35/64] bump nsp --- .gitignore | 3 ++- package.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 0d04d004..cc069782 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .DS_Store node_modules +package-lock.json examples/imgs/* !examples/imgs/original.jpg !examples/imgs/original.png @@ -10,4 +11,4 @@ examples/imgs/* !examples/imgs/orientation/*\d.jpg !examples/imgs/orientation/*.correct.jpg *.sw* -.idea \ No newline at end of file +.idea diff --git a/package.json b/package.json index 964d7e11..d8e8d212 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "license": "MIT", "devDependencies": { "async": "~0.9.0", - "nsp": "^2.8.1" + "nsp": "^3.2.1" }, "dependencies": { "array-parallel": "~0.1.3", From f404ee781e1daca08678524060b1d8fa2d3a0181 Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Sun, 11 Sep 2022 08:22:49 -0700 Subject: [PATCH 36/64] imagemagick and graphicsmagick now support webp out of the box --- README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/README.md b/README.md index 462e7925..c88f133c 100644 --- a/README.md +++ b/README.md @@ -13,11 +13,6 @@ First download and install [GraphicsMagick](http://www.graphicsmagick.org/) or [ brew install imagemagick brew install graphicsmagick -If you want WebP support, you must add the WebP option: - - brew install imagemagick --with-webp - brew install graphicsmagick --with-webp - then either use npm: npm install gm From 309e33440e4b35f0289a9889360562c4f3d10210 Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Sun, 11 Sep 2022 08:41:55 -0700 Subject: [PATCH 37/64] replace nsp w npm audit --- Makefile | 2 +- package.json | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index b2ed06c4..1776057e 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,6 @@ test-unit: security @node test/ $(TESTS) security: - @node_modules/.bin/nsp check + npm audit .PHONY: test test-unit security diff --git a/package.json b/package.json index d8e8d212..bf20e07f 100644 --- a/package.json +++ b/package.json @@ -36,8 +36,7 @@ }, "license": "MIT", "devDependencies": { - "async": "~0.9.0", - "nsp": "^3.2.1" + "async": "~0.9.0" }, "dependencies": { "array-parallel": "~0.1.3", From 7ee6276da6c51e87c69e6513a20fd723dabb7853 Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Sun, 18 Sep 2022 10:41:43 -0700 Subject: [PATCH 38/64] remove old test --- test/streamerr.js | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 test/streamerr.js diff --git a/test/streamerr.js b/test/streamerr.js deleted file mode 100644 index d9f6c23d..00000000 --- a/test/streamerr.js +++ /dev/null @@ -1,20 +0,0 @@ -var assert = require('assert') - -module.exports = function (_, dir, finish, gm) { - var svg_file; - svg_file = new Buffer('', 'ascii'); - - // The following invocation should fail, because 'convert' - // has no way of interpreting the file. - gm( - svg_file, - './test.svg' // fiction - ).options({ - imageMagick: true - }).setFormat('png').toBuffer(function(err, buffer) { - assert.ok(err, "Expecting error on this buffer"); - }); - - return finish(); - -} From 2ff6ddb9c72110ec33b868693f74bdbbdc43452c Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Sun, 18 Sep 2022 16:15:21 -0700 Subject: [PATCH 39/64] create workflow --- .github/workflows/node.js.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/node.js.yml diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 00000000..ece2201b --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,32 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: Node.js CI + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [14.x, 16.x, 18.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - name: Install GraphicsMagic and Imagemagick + run: sudo apt-get install -y imagemagick graphicsmagick + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm i + - run: npm test From d04a7abe816e9ceff381bbc8626d8b24833f383a Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Sun, 18 Sep 2022 16:30:36 -0700 Subject: [PATCH 40/64] Update node.js.yml --- .github/workflows/node.js.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index ece2201b..9d413122 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -27,6 +27,5 @@ jobs: uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - cache: 'npm' - run: npm i - run: npm test From 26197192f7f15ac856e151bad8e4cd632021d28a Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Sun, 18 Sep 2022 16:32:53 -0700 Subject: [PATCH 41/64] remove travis --- .travis.yml | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9185cd21..00000000 --- a/.travis.yml +++ /dev/null @@ -1,10 +0,0 @@ -before_install: - - sudo apt-get update - - sudo apt-get install imagemagick graphicsmagick -language: node_js -node_js: - - "8" - - "6" - - "4" - - "0.10" - - "0.12" From d01aa6f803a140f7de9fb3296b7f19429fe479df Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Sun, 18 Sep 2022 18:02:17 -0700 Subject: [PATCH 42/64] add temp test for 429 --- test/429.js | 27 +++++++++++++++++++++++++++ test/fixtures/test.ico | Bin 0 -> 5430 bytes 2 files changed, 27 insertions(+) create mode 100644 test/429.js create mode 100644 test/fixtures/test.ico diff --git a/test/429.js b/test/429.js new file mode 100644 index 00000000..36847721 --- /dev/null +++ b/test/429.js @@ -0,0 +1,27 @@ +const assert = require('assert'); +const fs = require('fs'); + +module.exports = function (gm, dir, finish, GM) { + if (!GM.integration) return finish(); + + // ico, buffer, stream + const ico = `${__dirname}/fixtures/test.ico`; + const buffer = fs.readFileSync(ico); + const stream = fs.createReadStream(ico); + + GM(ico).size(function (err, size) { + if (err) return finish(err); + console.log('string', size); + + GM(buffer, 'img.ico').size(function (err, size) { + if (err) return finish(err); + console.log('buffer', size); + + GM(stream, 'img.ico').size({bufferStream: true}, function (err, size) { + if (err) return finish(err); + console.log('stream', size); + finish(); + }); + }); + }); +} \ No newline at end of file diff --git a/test/fixtures/test.ico b/test/fixtures/test.ico new file mode 100644 index 0000000000000000000000000000000000000000..78713f95a2a32253a8990262b7f3c687dacc1ac0 GIT binary patch literal 5430 zcmeHLdr(wW7(e&2iNhbsG&WHYkeLrqLoJ&e1;)&A_=AeZ$w+HN5JF?dMnepb?eCHCv5uUiX5ExxZu00_$2qE?`;_qMyAq{Xp3+CVv;swBY!v*uhFUA;oiYLPc zbZF2~f4|?Inqau6)b4TluR6oy{EZ`osnU(;QW93FT%Gf{_|GfXD7%4EB{xEoN!ah{ zPU^wIdy^(whmLmj^xCTOC3U}6E=F7gl*j|*-9MPuug)N>EpzffXNTHpqWO<){-9Ad zo3I3TBVt_%%UZ=#jl#^2e(25u8`Pcim}vgvyVm~_1N?Ds7$J2dENul(+cFSl9eT1M z21*VFOf>(=RM{RGtXT&9h?u#ACBMVd=I?l_K4j+Cfy7t3nevE-@nfAA<3brIx6-9@iE!rE}c;V#ATiUMYA4R9j^|cRa==CoT}}<;V>ROy1Q;VM$er*up8n};E$R`*vX9& zT?gi%sRmdY+rdXYIfPwRPHR=GnrB$6gKltelFVybYrKd*8tjp^N}}t6_uhc@c8Y*H zwL?7+$0q951<(AUaBmzKxNB>z4#|GYPbG@@(GF5Tny(F2thJ#>KDD9B&z{l!xPhmo zVLZK*4EYK5akzglN2-2K3$&L1;Py@Xk{6imkGUv?JP3S=W9u9^<}X43%zZhXV~NXc zXhjrHJHZ};Ejl1xYYr_bx0b&!<3P|J5x)=zp|5c)*o9+X3`39;==37THoU^I+yI_- zK&?U@+Q1Lj(x2_4LprN+qWa9~W#aWCKgQ!%uLHmHgZzR%20g$wg&U1_z&Jo1aKE(1 z2JLMs=lC}#-HQ{&0P=^;+&X@!eQoCC-o z4t3yR{HVja7dWO^%hQ{X11*Q_Z_}as&soEd&!(*LIxEfrv_<3`@__FJ+l$A*mpQg` z5yyISA^r<@MOn*@&!>MAoGOk1%z+rF#UZa6eSmhb2#Ck6vpIGqds`f(L)>`ykIDCj z4$lG90euiQ(=xV0t=t8B=5Bblx#_a&c(_rfx~yb{c>O{Sq8~689)_g(gf-S)cx$}; zs+PZ|$1jxVaLoeuSVxT8#HCZUy}h@mjF-Q^|BhYKyN()h4vd8#_5F4sVFd>gwv3ls zkc;8j8a|uPRCY zI=7-gu^IYTtM}YT(ebJ5lW~R|!A~$Hy3`SjnJ`2mm=T^#Pn-d;hY}J2@HD}h5%}Xl zc(OuMU(*N;`llD#_<^LO~m^TWK0uS3sj=ub|E>>sPV+;8zEtbqxOc-kuGDav2T zUsg6&`P?mQa#0@6RJ19@DBqec(Ot>&IDfUsw?I>$7C73O`qX~uPOPtZCai&86VF2k z;arAmYANzAwzTKgo;doEP|qXh6B@PHhQ=)A>46V^ny5I-<9KUd`C}RWb#PzxTnOwZP$-Bz+Og>7kU@$9~%-0?Wv1M8c81KQhZ#S z3^s&b1bbn8hX9n%32{>QX;sdaJ)#X`fL8Hn3KmS4TfkHC`P)C^HOh})t S2{teygx^yLxd;EF4B{VbL36kO literal 0 HcmV?d00001 From a7f20dcd5ba92b602d2a7734ba04cf2542c1bcf6 Mon Sep 17 00:00:00 2001 From: freund17 Date: Thu, 11 Jan 2018 17:48:46 +0100 Subject: [PATCH 43/64] added format inference from the filename added format inference from the filename for input buffers or streams Fixes https://github.com/aheckmann/gm/issues/429 --- index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 8f5f8d54..d63c3b05 100644 --- a/index.js +++ b/index.js @@ -72,7 +72,17 @@ function gm (source, height, color) { // must be first source formatter var inputFromStdin = this.sourceStream || this.sourceBuffer; - var ret = inputFromStdin ? '-' : this.source; + var ret = this.source; + + if (inputFromStdin) { + var format = ''; + + if (this.source) { + format = this.source.split('.').pop() + ':'; + } + + ret = format + '-'; + } if (ret && this.sourceFrames) ret += this.sourceFrames; From c63473ae17ecd7de191b90ef3bae94bb0333c8aa Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Sun, 18 Sep 2022 18:11:46 -0700 Subject: [PATCH 44/64] finish fix for #429 --- index.js | 13 ++++--------- test/429.js | 19 ++++++++++++------- test/getterIdentify.js | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/index.js b/index.js index d63c3b05..30d34971 100644 --- a/index.js +++ b/index.js @@ -72,16 +72,11 @@ function gm (source, height, color) { // must be first source formatter var inputFromStdin = this.sourceStream || this.sourceBuffer; - var ret = this.source; + var ret = inputFromStdin ? '-' : this.source; - if (inputFromStdin) { - var format = ''; - - if (this.source) { - format = this.source.split('.').pop() + ':'; - } - - ret = format + '-'; + const fileNameProvied = typeof height === 'string'; + if (inputFromStdin && fileNameProvied && /\.ico$/i.test(this.source)) { + ret = `ico:-`; } if (ret && this.sourceFrames) ret += this.sourceFrames; diff --git a/test/429.js b/test/429.js index 36847721..c6df739a 100644 --- a/test/429.js +++ b/test/429.js @@ -4,22 +4,27 @@ const fs = require('fs'); module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - // ico, buffer, stream const ico = `${__dirname}/fixtures/test.ico`; const buffer = fs.readFileSync(ico); const stream = fs.createReadStream(ico); GM(ico).size(function (err, size) { - if (err) return finish(err); - console.log('string', size); + if (err) { + err.message = 'Failed using ico filename. ' + err.message; + return finish(err); + } GM(buffer, 'img.ico').size(function (err, size) { - if (err) return finish(err); - console.log('buffer', size); + if (err) { + err.message = 'Failed using ico buffer. ' + err.message; + return finish(err); + } GM(stream, 'img.ico').size({bufferStream: true}, function (err, size) { - if (err) return finish(err); - console.log('stream', size); + if (err) { + err.message = 'Failed using ico stream. ' + err.message; + return finish(err); + } finish(); }); }); diff --git a/test/getterIdentify.js b/test/getterIdentify.js index 571814d5..08a62f57 100755 --- a/test/getterIdentify.js +++ b/test/getterIdentify.js @@ -4,7 +4,7 @@ var os = require('os') var isLinux = os.platform() === 'linux' // Be more lax with the errors if we're on linux -var errorFactor = isLinux ? 10 : 1 +var errorFactor = isLinux ? 10 : 1.1 module.exports = function (_, dir, finish, gm) { if (!gm.integration) From d0c39abf5d0bdf686373ac824fecdb262abef145 Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Sun, 18 Sep 2022 21:05:57 -0700 Subject: [PATCH 45/64] add test for 714 --- test/autoOrient.js | 8 ++------ test/autoOrientAll.js | 2 -- test/autoOrientStream.js | 7 ++----- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/test/autoOrient.js b/test/autoOrient.js index 677d0c8f..2a9806d2 100644 --- a/test/autoOrient.js +++ b/test/autoOrient.js @@ -9,11 +9,10 @@ module.exports = function (_, dir, finish, gm) { var filename = dir + '/autoOrient.jpg'; - gm(dir + '/originalSideways.jpg').orientation(function (err, o) { + gm(dir + '/originalSideways.jpg').identify(function (err, o) { if (err) return finish(err); - assert.equal('RightTop', o); - assert.ok(!! this.data['Profile-EXIF'], 'No Profile-EXIF data found'); + assert.equal('155x460', o.Geometry); // this image is sideways, but may be auto-oriented by modern OS's // try opening it in a browser to see its true orientation @@ -25,10 +24,7 @@ module.exports = function (_, dir, finish, gm) { gm(stream).identify(function (err, data) { if (err) return finish(err); - assert.equal('Unknown', data.Orientation); - assert.ok(! this.data['Profile-EXIF'], 'Profile-EXIF still exists'); assert.equal('460x155', data.Geometry); - finish(err); }) }) diff --git a/test/autoOrientAll.js b/test/autoOrientAll.js index 7f758735..3fb07a0f 100644 --- a/test/autoOrientAll.js +++ b/test/autoOrientAll.js @@ -85,8 +85,6 @@ module.exports = function (_, dir, finish, gm) { gm(newFilename).identify(function (err) { if (err) return finish(err); - assert.equal('Unknown', this.data.Orientation); - assert.ok(!this.data['Profile-EXIF']) assert.equal(afterValues[filename], this.data.Geometry, 'Bad-Geometry for ' + filename); gm.compare(newFilename, constant, 0.1, function (err, equal) { diff --git a/test/autoOrientStream.js b/test/autoOrientStream.js index c4177136..8b4ea18f 100644 --- a/test/autoOrientStream.js +++ b/test/autoOrientStream.js @@ -11,11 +11,10 @@ module.exports = function (_, dir, finish, gm) { var filename = dir + '/autoOrientStream.jpg'; - gm(fs.createReadStream(dir + '/originalSideways.jpg')).orientation(function (err, o) { + gm(fs.createReadStream(dir + '/originalSideways.jpg')).identify(function (err) { if (err) return finish(err); - assert.equal('RightTop', o); - assert.ok(!! this.data['Profile-EXIF'], 'No Profile-EXIF data found'); + assert.equal('155x460', this.data.Geometry); // this image is sideways, but may be auto-oriented by modern OS's // try opening it in a browser to see its true orientation @@ -29,8 +28,6 @@ module.exports = function (_, dir, finish, gm) { gm(filename).identify(function (err) { if (err) return finish(err); - assert.equal('Unknown', this.data.Orientation); - assert.ok(! this.data['Profile-EXIF'], 'Profile-EXIF still exists'); assert.equal('460x155', this.data.Geometry); finish(err); From 8e0f0cb4c40fd8c1485dd54d584d34023e45d073 Mon Sep 17 00:00:00 2001 From: Christof Haemmerle Date: Tue, 3 Apr 2018 23:43:57 -0400 Subject: [PATCH 46/64] stip removes the the colorprofile which results in wrong colors for images with AdobeRGB profile --- lib/convenience/autoOrient.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/convenience/autoOrient.js b/lib/convenience/autoOrient.js index e16c2a92..a9c0e283 100644 --- a/lib/convenience/autoOrient.js +++ b/lib/convenience/autoOrient.js @@ -25,7 +25,7 @@ module.exports = function (proto) { // nativeAutoOrient option enables this if you know you have >= 1.3.18 if (this._options.nativeAutoOrient || this._options.imageMagick) { this.out('-auto-orient'); - this.strip(); + // this.strip(); return this; } @@ -46,7 +46,7 @@ module.exports = function (proto) { this._out.unshift.apply(this._out, transforms.concat('-page', '+0+0')); } - this.strip(); + // this.strip(); callback(); }); From 41a2cb90e0c5d092f7baac6cda66a251496b9d3f Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Sun, 18 Sep 2022 21:08:50 -0700 Subject: [PATCH 47/64] do not strip during autoOrient #714 --- lib/convenience/autoOrient.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/convenience/autoOrient.js b/lib/convenience/autoOrient.js index a9c0e283..78ff2d18 100644 --- a/lib/convenience/autoOrient.js +++ b/lib/convenience/autoOrient.js @@ -25,7 +25,6 @@ module.exports = function (proto) { // nativeAutoOrient option enables this if you know you have >= 1.3.18 if (this._options.nativeAutoOrient || this._options.imageMagick) { this.out('-auto-orient'); - // this.strip(); return this; } @@ -46,8 +45,6 @@ module.exports = function (proto) { this._out.unshift.apply(this._out, transforms.concat('-page', '+0+0')); } - // this.strip(); - callback(); }); }); From 23ab2c1f136e3cf1dc13a0d8159b664963a93115 Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Sun, 18 Sep 2022 21:25:02 -0700 Subject: [PATCH 48/64] 1.24.0 --- History.md | 8 ++++++++ package.json | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/History.md b/History.md index f9f30769..32c50943 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,11 @@ +1.24.0 / 2022-09-18 + +* fixed: infering format of buffered or streamed ico files #429 freund17 +* fixed; preserve color info duing autoOrient() #714, #844 reco +* tests; switch to Github Actions +* docs; fix links #834 delesseps +* docs; clarify install directions #689 PatrykMiszczak +* refactor; clean up compare.js #788 LongTengDao 1.23.1 / 2017-12-27 diff --git a/package.json b/package.json index bf20e07f..aa5a8d4c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "gm", "description": "GraphicsMagick and ImageMagick for node.js", - "version": "1.23.1", + "version": "1.24.0", "author": "Aaron Heckmann ", "keywords": [ "graphics", @@ -15,7 +15,7 @@ "compare" ], "engines": { - "node": ">= 0.10.0" + "node": ">=14" }, "bugs": { "url": "http://github.com/aheckmann/gm/issues" From ed041fe6d25e7bf35727c9aa6217111b4bbc86f8 Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Mon, 19 Sep 2022 06:37:43 -0700 Subject: [PATCH 49/64] clean up a bit --- lib/command.js | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/lib/command.js b/lib/command.js index 2ff464fe..8f09f5ab 100644 --- a/lib/command.js +++ b/lib/command.js @@ -35,7 +35,7 @@ module.exports = function (proto) { return this; } } - + function streamToUnemptyBuffer(stream, callback) { var done = false var buffers = [] @@ -45,19 +45,18 @@ module.exports = function (proto) { }) stream.on('end', function () { - var result, err; if (done) return done = true - result = Buffer.concat(buffers) + let result = Buffer.concat(buffers) buffers = null - if (result.length==0) - { - err = new Error("Stream yields empty buffer"); - callback(err, null); + + if (result.length === 0) { + const err = new Error("Stream yields empty buffer"); + callback(err, null); } else { - callback(null, result); + callback(null, result); } }) @@ -196,7 +195,7 @@ module.exports = function (proto) { * @param {Array} args * @param {ReadableStream} stream * @param {Boolean} shouldBuffer - * @param {Function} callback, signature (err, stdout, stderr) -> * + * @param {Function} callback, signature (err, stdout, stderr) -> * * @return {Object} gm * @TODO refactor this mess */ @@ -217,8 +216,7 @@ module.exports = function (proto) { debug(cmd); //imageMagick does not support minify (https://github.com/aheckmann/gm/issues/385) if(args.indexOf("-minify") > -1 && this._options.imageMagick){ - err = new Error("imageMagick does not support minify, use -scale or -sample. Alternatively, use graphicsMagick"); - return cb(err); + return cb(new Error("imageMagick does not support minify, use -scale or -sample. Alternatively, use graphicsMagick")); } try { proc = spawn(bin, args); @@ -226,7 +224,7 @@ module.exports = function (proto) { return cb(e); } proc.stdin.once('error', cb); - + proc.on('error', function(err){ if (err.code === 'ENOENT') { cb(new Error('Could not execute GraphicsMagick/ImageMagick: '+cmd+" this most likely means the gm/convert binaries can't be found")); @@ -255,8 +253,7 @@ module.exports = function (proto) { } else if (self.sourceStream) { if (!self.sourceStream.readable) { - err = new Error("gm().stream() or gm().write() with a non-readable stream."); - return cb(err); + return cb(new Error("gm().stream() or gm().write() with a non-readable stream.")); } self.sourceStream.pipe(proc.stdin); @@ -297,6 +294,7 @@ module.exports = function (proto) { }); proc.on('close', onExit = function (code, signal) { + let err; if (code !== 0 || signal !== null) { err = new Error('Command failed: ' + stderr); err.code = code; @@ -316,15 +314,15 @@ module.exports = function (proto) { if (timeoutId) clearTimeout(timeoutId); cb.called = 1; if (args[0] !== 'identify' && bin !== 'identify') { - self._in = []; - self._out = []; + self._in = []; + self._out = []; } callback.call(self, err, stdout, stderr, cmd); } function dispose (msg) { - var message = msg ? msg : 'gm() was disposed'; - err = new Error(message); + const message = msg ? msg : 'gm() was disposed'; + const err = new Error(message); cb(err); if (proc.exitCode === null) { proc.stdin.pause(); From 1ebb09c06287ad0d74be101cf715beb1e77d0989 Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Mon, 19 Sep 2022 06:42:42 -0700 Subject: [PATCH 50/64] docs --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 47809d57..84fecd5c 100644 --- a/README.md +++ b/README.md @@ -24,11 +24,14 @@ or clone the repo: ## Use ImageMagick instead of gm -Subclass `gm` to enable ImageMagick +Subclass `gm` to enable ImageMagick, optionally specifying the path to the executable. ```js -var fs = require('fs') - , gm = require('gm').subClass({imageMagick: true}); +const fs = require('fs') +const gm = require('gm').subClass({ + imageMagick: true, + appPath: String.raw`C:\Program Files\ImageMagick-7.1.0-Q16-HDRI\magick.exe` +}); // resize and remove EXIF profile data gm('/path/to/my/img.jpg') From ef6d183df531fb4b06e716597bc05655a66969f6 Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Mon, 19 Sep 2022 06:51:48 -0700 Subject: [PATCH 51/64] docs --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c2082429..d3f25455 100644 --- a/README.md +++ b/README.md @@ -622,8 +622,14 @@ http://github.com/quiiver/magickal-node ## Plugins [https://github.com/aheckmann/gm/wiki](https://github.com/aheckmann/gm/wiki) -## Tests -node test --integration --only pdf-noncompliant.js +## Tests +`npm test` + +To run a single test: + +``` +node test --integration pdf-noncompliant.js +``` ## License From 16385dc8fe50a350469e158457f10dd794fefbcb Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Wed, 21 Sep 2022 06:42:58 -0700 Subject: [PATCH 52/64] Revert "Merge pull request #821 from agokhale/pdf-noncompliant" This reverts commit 18086160455d77a3b75d3ee5f3dc7d9495032477, reversing changes made to 1ebb09c06287ad0d74be101cf715beb1e77d0989. Tests were flakey. --- README.md | 9 --------- lib/command.js | 6 +----- lib/nuisanceConsumer.js | 10 ---------- test/fixtures/synthetic_invalid.pdf | Bin 8536 -> 0 bytes test/pdf-noncompliant.js | 20 -------------------- 5 files changed, 1 insertion(+), 44 deletions(-) delete mode 100644 lib/nuisanceConsumer.js delete mode 100644 test/fixtures/synthetic_invalid.pdf delete mode 100644 test/pdf-noncompliant.js diff --git a/README.md b/README.md index d3f25455..84fecd5c 100644 --- a/README.md +++ b/README.md @@ -622,15 +622,6 @@ http://github.com/quiiver/magickal-node ## Plugins [https://github.com/aheckmann/gm/wiki](https://github.com/aheckmann/gm/wiki) -## Tests -`npm test` - -To run a single test: - -``` -node test --integration pdf-noncompliant.js -``` - ## License (The MIT License) diff --git a/lib/command.js b/lib/command.js index 7ef7150a..8f09f5ab 100644 --- a/lib/command.js +++ b/lib/command.js @@ -8,7 +8,6 @@ var utils = require('./utils'); var debug = require('debug')('gm'); var series = require('array-series'); var PassThrough = require('stream').PassThrough; -var nuisanceConsumer = require('./nuisanceConsumer'); /** * Error messaging. @@ -287,10 +286,7 @@ module.exports = function (proto) { , onExit proc.stdout.on('data', onOut = function (data) { - if ( nuisanceConsumer.isNuisance( data ) == 1 ) - { /*console.log("elided", data); */ stderr+= data; } - else - {stdout += data;} + stdout += data; }); proc.stderr.on('data', onErr = function (data) { diff --git a/lib/nuisanceConsumer.js b/lib/nuisanceConsumer.js deleted file mode 100644 index df848807..00000000 --- a/lib/nuisanceConsumer.js +++ /dev/null @@ -1,10 +0,0 @@ -//issues/820 - -module.exports = exports = {}; -exports.isNuisance = function(instring) { - //console.log ("wat", instring.toString(), typeof(instring)); - // scan each emitted line, if it's an error line, remove it -//**** Error: stream operator isn't terminated by valid EOL. - if( instring.toString().indexOf ("**** Error: stream operator isn't terminated by valid EOL.") > 1) { return 1 } - return 0 ; -} diff --git a/test/fixtures/synthetic_invalid.pdf b/test/fixtures/synthetic_invalid.pdf deleted file mode 100644 index acdab0c8d2e1a275b337e81a523a6bf77e39b722..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8536 zcmaiZ1z1#D+qOz6NDC-ANJ`BxFhNLncQ*_TgD^CRNJ&e#7<7YlNjK7+N(m?>O3Odv zIp;m+{m%DY|DJ2j-uqckuY0YzuDMy%q-3~xd7y+WojIM&owc3WgkS&&fV8kD6cz?5 zA)IYcwg5h~L<1;e=ZHeM0%aV{Q3xr7CDIBZB7*ORaz&Us5qf2^L_Q|y5F?SgxS}v5 z5U`n9q@u->u{5WGSC9z3%QB&C-W zLed#F6fEC_v;M-WrhX`ek8rm7Gad93x&nNBOyZaaUOq5p_O}f3r|j?Yp#MjCf0oY+ z;N=B@LH{gvL%`RCW+Q6_sS7kruBj>wdnadrSZj9FuiXfSGavR4&xL2{#W-=Kkto($ zDVixpCQSvh{pP-^h@k?LutEi!_ zU%PMirAV&{8P6RBlZK`HjU$6gme{^er0F$Yj~!BxUSl(Uy_0kESD!4-bLs~+dPxTF zrjn9&IqxQ|U$49oQ5nk7ZHc}wpKbyan$^rn7MAGyoB^)&8$JQHo&-DyDRa5FdqyT8 z8IzD5PjfFc8(Z!5mUT0H|0``qGSk+Z+8St z@xJr&fh$4Jk^7ORE$d3Jx_n%nxa_aw<`+6EGV^=IX%_2@={c)bcYfHczaQeQiWG?L zV*-aAf@!@2g>f&&T#3F5wJ~NAsf#yWPq4yE z;~De96&XpkybkT(s>~bFOt0&k{8nNWr3$%aE*&yboEH;&1m8D% zY$!WW)`Ktz=e?$%s5&KTN>5CP>yDJ3w^;eiFe@igNUd3_h16_0Ru|zvDY90};QGZ8 zpeRzb{O%W-2Z1Mk<<|L_nv0c}?Y^0r*~s3nR%0Pw-^(TAEIOgCpWha0O`39@zC$vg zP?$H(W5V6(vO+`d64xe229e_2VpEC9g1F>rKCQ-kK|v-`K6{zuX1Zh5Gg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l7Ra_*!GGw@t3>*k;3ey|M23U|DWZdw1PHyg@2@9N2BHUd0boIjECRwk@IGT7b zr>2iYJu)Yn>Mz%qW~^;=8wCangYe>;4esb{2Re%sP4|AY7@~@LO^3+gDhys8@!s4F ziGBInenHMu$9c)8-?Y;SBE}arQ6G`YJQPY$VMHv3-=kn)RL*jf`+90zSfSCx&vn;O zb7es9DaT`*zA(jAx}!r9cTH<^$}C(4JB!7?ur3{lKG#{ylC|3+F7A&-3(!9 z!0_?$0U#jI@4=6T5(Y$=fsuhBf52Wla;o$WAW zCIEw!e?W(jkQelKVKTe`Oqm*lA|ix;Knp$3`;U2aWq{uX8iYVKSEQvT0%Zt9ldC{2 zgcr*Azs&x&`rQ~ca~lLu&D<4(bAC(=pa#MX>F#QYa6>bXzXi$&D?4+{_Q7NXJN_bd$}U-CQs(EWLq}n&@rgVP}cZkd*++15oG%5D@`Nq7y_%a06iI zU5$Ti5KKtS#{X;eFzLAA|0@T4;D3@p8~i5=Ok)-8tlSI%zcakHA>Vj|ggK*oZTHA|M&u-eJhze+pr^?xwSPP z{d1G^{zdeni;zSU(&)oUSVme#1_Xk@Kp+?x1cC~n@BHXH8YnQZ2tH;Be9>+z%Qq0m1E+8)Y>9%wmQ1;mH;3zkOTL15-QEAzgF)f{l7Ybd|B^wWQ1p5E-?mUF9Q{-9KV)z?dPV+Q1_Sf`OAp2m`Bw}W zKOBv)|6vRJU;M#g=neRn9?I1meVn^uK&ffxgFv?msDVVHQHA!8*|qY{)=0qbRmZ$Y z0Sp1c{CqID1Qa3wg788Fc%@+ie3CMJGSa+oxFnPxj9K&lzX}GvQb Date: Mon, 19 Sep 2022 07:22:40 -0700 Subject: [PATCH 53/64] Squashed commit of the following: commit f7cc29215a42e35efc9050955d12c0c961c842ad Author: Piotr Konieczny Date: Wed Jan 23 13:42:13 2019 +0100 Updating README commit b740a6c7ae05689555b7f03dea6fe5737850dd2f Author: Piotr Konieczny Date: Wed Jan 23 13:37:35 2019 +0100 Fix ImageMagick 7+ Co-authored-by: Piotr Konieczny --- README.md | 9 +++++++++ lib/command.js | 25 ++++++++++++++++++++++--- lib/compare.js | 25 +++++++++++++++++++------ 3 files changed, 50 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 99ac27f8..7991ef03 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,15 @@ gm('/path/to/my/img.jpg') ... ``` +Subclass `gm` to enable ImageMagick 7+ + +```js +var fs = require('fs') + , gm = require('gm').subClass({imageMagick: '7+'}); + +... +``` + ## Basic Usage diff --git a/lib/command.js b/lib/command.js index 8f09f5ab..20110c8b 100644 --- a/lib/command.js +++ b/lib/command.js @@ -202,9 +202,28 @@ module.exports = function (proto) { proto._spawn = function _spawn (args, bufferOutput, callback) { var appPath = this._options.appPath || ''; - var bin = this._options.imageMagick - ? appPath + args.shift() - : appPath + 'gm' + var bin + + // Resolve executable + switch (this._options.imageMagick) { + // ImgeMagick < 7 or >= 7 with legacy utilities (convert) + case true: + bin = args.shift(); + break; + + // ImgeMagick >= 7 + case '7+': + bin = 'magick' + break; + + // GraphicsMagick + default: + bin = 'gm'; + break; + } + + // Prepend app path + bin = appPath + bin var cmd = bin + ' ' + args.map(utils.escape).join(' ') , self = this diff --git a/lib/compare.js b/lib/compare.js index c39ac490..0f9ea129 100644 --- a/lib/compare.js +++ b/lib/compare.js @@ -22,13 +22,26 @@ module.exports = exports = function (proto) { var isImageMagick = this._options && this._options.imageMagick; var appPath = this._options && this._options.appPath || ''; - var bin = isImageMagick - ? appPath + 'compare' - : appPath + 'gm' - var args = ['-metric', 'mse', orig, compareTo] - if (!isImageMagick) { - args.unshift('compare'); + + // Resove executable + var bin + + switch (isImageMagick) { + case true: + bin = 'compare'; + break; + case '7+': + bin = 'magick compare' + break; + default: + bin = 'gm compare' + break } + + // Prepend app path + bin = appPath + bin + + var args = ['-metric', 'mse', orig, compareTo] var tolerance = 0.4; // outputting the diff image if (typeof options === 'object') { From 9879a1222d4c4ba9b68498d2c6263e95887ba075 Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Mon, 19 Sep 2022 07:44:47 -0700 Subject: [PATCH 54/64] fix gm compare after the imagemagick 7+ changes --- lib/command.js | 28 ++++++++++++++-------------- lib/compare.js | 28 +++++++++++++++------------- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/lib/command.js b/lib/command.js index 20110c8b..46930cdc 100644 --- a/lib/command.js +++ b/lib/command.js @@ -206,20 +206,20 @@ module.exports = function (proto) { // Resolve executable switch (this._options.imageMagick) { - // ImgeMagick < 7 or >= 7 with legacy utilities (convert) - case true: - bin = args.shift(); - break; - - // ImgeMagick >= 7 - case '7+': - bin = 'magick' - break; - - // GraphicsMagick - default: - bin = 'gm'; - break; + // legacy behavior + case true: + bin = args.shift(); + break; + + // ImgeMagick >= 7 + case '7+': + bin = 'magick' + break; + + // GraphicsMagick + default: + bin = 'gm'; + break; } // Prepend app path diff --git a/lib/compare.js b/lib/compare.js index 0f9ea129..f85b288f 100644 --- a/lib/compare.js +++ b/lib/compare.js @@ -22,26 +22,28 @@ module.exports = exports = function (proto) { var isImageMagick = this._options && this._options.imageMagick; var appPath = this._options && this._options.appPath || ''; + var args = ['-metric', 'mse', orig, compareTo]; // Resove executable - var bin + let bin; switch (isImageMagick) { - case true: - bin = 'compare'; - break; - case '7+': - bin = 'magick compare' - break; - default: - bin = 'gm compare' - break + case true: + bin = 'compare'; + break; + case '7+': + bin = 'magick' + args.unshift('compare'); + break; + default: + bin = 'gm' + args.unshift('compare'); + break } // Prepend app path bin = appPath + bin - var args = ['-metric', 'mse', orig, compareTo] var tolerance = 0.4; // outputting the diff image if (typeof options === 'object') { @@ -69,13 +71,13 @@ module.exports = exports = function (proto) { } args.push(options.file); } - + if (typeof options.tolerance != 'undefined') { if (typeof options.tolerance !== 'number') { throw new TypeError('The tolerance value should be a number'); } tolerance = options.tolerance; - } + } } else { // For ImageMagick diff file is required but we don't care about it, so null it out if (isImageMagick) { From d8ff6d7de3ec16771e0d8899e54772f6b9c2f64e Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Mon, 19 Sep 2022 07:45:16 -0700 Subject: [PATCH 55/64] test; add imagemagick 7+ tests --- test/index.js | 15 ++++++++++++--- test/subclass.js | 4 +++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/test/index.js b/test/index.js index 84c2f89a..c18d9f1e 100644 --- a/test/index.js +++ b/test/index.js @@ -22,9 +22,11 @@ function filter (file) { return true; } -function test (imagemagick) { - if (imagemagick) - return gm(dir + '/original.jpg').options({ imageMagick: true }); +function test (imageMagick) { + if (imageMagick) { + return gm(dir + '/original.jpg').options({ imageMagick }); + } + return gm(dir + '/original.jpg'); } @@ -78,3 +80,10 @@ files.forEach(function (file) { filename: file }) }) + +files.forEach(function (file) { + q.push({ + imagemagick: '7+', + filename: file + }) +}) diff --git a/test/subclass.js b/test/subclass.js index 99018c04..08ee5b15 100644 --- a/test/subclass.js +++ b/test/subclass.js @@ -2,7 +2,6 @@ var assert = require('assert') module.exports = function (_, dir, finish, gm) { - assert.equal('gm', gm('test').constructor.name); assert.equal(undefined, gm.prototype._options.imageMagick); @@ -18,6 +17,9 @@ module.exports = function (_, dir, finish, gm) { var g = gm('test'); assert.equal(undefined, g._options.imageMagick); + var imageMagick7 = gm.subClass({ imageMagick: '7+'}); + assert.equal('7+', imageMagick7.prototype._options.imageMagick); + if (!gm.integration) return finish(); From e47ca8e402d2e4c6774eea7f1c037dbbe8ff5196 Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Mon, 19 Sep 2022 08:11:55 -0700 Subject: [PATCH 56/64] debug compare --- lib/compare.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/compare.js b/lib/compare.js index f85b288f..7ba33976 100644 --- a/lib/compare.js +++ b/lib/compare.js @@ -1,6 +1,8 @@ // compare var spawn = require('cross-spawn'); +var debug = require('debug')('gm'); +var utils = require('./utils'); /** * Compare two images uses graphicsmagicks `compare` command. @@ -91,6 +93,9 @@ module.exports = exports = function (proto) { } } + var cmd = bin + ' ' + args.map(utils.escape).join(' ') + debug(cmd); + var proc = spawn(bin, args); var stdout = ''; var stderr = ''; From 9c7cac396178baa1c45916ba269276d91f49b73f Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Mon, 19 Sep 2022 08:20:43 -0700 Subject: [PATCH 57/64] docs --- README.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 7991ef03..71859843 100644 --- a/README.md +++ b/README.md @@ -24,30 +24,30 @@ or clone the repo: ## Use ImageMagick instead of gm -Subclass `gm` to enable ImageMagick, optionally specifying the path to the executable. +Subclass `gm` to enable [ImageMagick 7+](https://imagemagick.org/script/porting.php) ```js const fs = require('fs') -const gm = require('gm').subClass({ - imageMagick: true, - appPath: String.raw`C:\Program Files\ImageMagick-7.1.0-Q16-HDRI\magick.exe` -}); - -// resize and remove EXIF profile data -gm('/path/to/my/img.jpg') -.resize(240, 240) -... +const gm = require('gm').subClass({ imageMagick: '7+' }); ``` -Subclass `gm` to enable ImageMagick 7+ +Or, to enable ImageMagick legacy mode (for ImageMagick version < 7) ```js -var fs = require('fs') - , gm = require('gm').subClass({imageMagick: '7+'}); - -... +const fs = require('fs') +const gm = require('gm').subClass({ imageMagick: true }); ``` +## Specify the executable path + +Optionally specify the path to the executable. + +```js +const fs = require('fs') +const gm = require('gm').subClass({ + appPath: String.raw`C:\Program Files\ImageMagick-7.1.0-Q16-HDRI\magick.exe` +}); +``` ## Basic Usage From e4f2ff71d77cd888eeb1163c737a380faf4d7ddd Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Mon, 19 Sep 2022 06:58:13 -0700 Subject: [PATCH 58/64] tests; windows support --- .github/workflows/node.js.yml | 20 ++++++++-- Makefile | 11 ----- package.json | 7 +++- test/109.js | 17 ++++---- test/118.js | 15 +++---- test/393.js | 10 ++--- test/417.js | 21 +++++----- test/422.js | 38 +++++++++++------- test/429.js | 3 +- test/70.js | 10 ++--- test/78.js | 15 +++---- test/alpha.js | 35 +++++++++------- test/append.js | 32 ++++++++------- test/arc.js | 12 +++--- test/autoOrient.js | 12 +++--- test/autoOrientAll.js | 22 +++++----- test/autoOrientAndThumb.js | 9 ++--- test/autoOrientStream.js | 12 +++--- test/background.js | 8 ++-- test/bezier.js | 6 +-- test/bitdepth.js | 8 ++-- test/blur.js | 7 ++-- test/changeFormat.js | 7 ++-- test/charcoal.js | 8 ++-- test/chop.js | 8 ++-- test/circle.js | 9 ++--- test/colorize.js | 8 ++-- test/colors.js | 8 ++-- test/comment.js | 8 ++-- test/compare.js | 32 ++++++++++----- test/composite.js | 21 +++++----- test/contrast.js | 18 ++++----- test/crop.js | 20 +++++----- test/cycle.js | 14 +++---- test/densityGm.js | 11 ++--- test/index.js | 75 ++++++++++++++++++++--------------- 36 files changed, 305 insertions(+), 272 deletions(-) delete mode 100644 Makefile diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 9d413122..2bfbe4bf 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -11,21 +11,33 @@ on: jobs: build: - - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: matrix: + os: [ubuntu-latest, windows-latest] node-version: [14.x, 16.x, 18.x] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: - - name: Install GraphicsMagic and Imagemagick + - name: Install GraphicsMagic and Imagemagick on Ubuntu + if: contains(matrix.os, 'ubuntu') run: sudo apt-get install -y imagemagick graphicsmagick + - name: Install GraphicsMagic and Imagemagick on Windows + if: contains(matrix.os, 'windows') + run: choco install -y imagemagick graphicsmagick - uses: actions/checkout@v3 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - run: npm i - - run: npm test + - name: Run tests on Windows + if: contains(matrix.os, 'windows') + shell: cmd + run: | + call refreshenv + npm test + - name: Run tests on Ubuntu + if: contains(matrix.os, 'ubuntu') + run: npm test \ No newline at end of file diff --git a/Makefile b/Makefile deleted file mode 100644 index 1776057e..00000000 --- a/Makefile +++ /dev/null @@ -1,11 +0,0 @@ - -test: security - @node test/ --integration $(TESTS) - -test-unit: security - @node test/ $(TESTS) - -security: - npm audit - -.PHONY: test test-unit security diff --git a/package.json b/package.json index aa5a8d4c..48988a4f 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,10 @@ ], "main": "./index", "scripts": { - "test": "make test;" + "security": "npm audit", + "test": "npm run security && npm run test-integration", + "test-integration": "node test/ --integration", + "test-unit": "node test/" }, "repository": { "type": "git", @@ -44,4 +47,4 @@ "cross-spawn": "^4.0.0", "debug": "^3.1.0" } -} +} \ No newline at end of file diff --git a/test/109.js b/test/109.js index 55992c28..70cb3adc 100644 --- a/test/109.js +++ b/test/109.js @@ -1,17 +1,14 @@ -var assert = require('assert') -var fs = require('fs') +const fs = require('fs'); +const path = require('path'); module.exports = function (_, dir, finish, gm) { - if (!gm.integration) - return finish(); + if (!gm.integration) return finish(); - var original = dir + '/original.jpg'; - var result = dir + '/fromBuffer.png'; + const original = path.join(dir, 'original.jpg'); + const buf = fs.readFileSync(original); + const m = gm(buf, 'original.jpg'); - var buf = fs.readFileSync(original); - var m = gm(buf, 'original.jpg'); - - m.identify(function (err, x) { + m.identify(function (err, _) { finish(err); }); diff --git a/test/118.js b/test/118.js index fad472eb..8048ec3f 100644 --- a/test/118.js +++ b/test/118.js @@ -1,18 +1,19 @@ /* - * If only the width is specified for a resize operation, + * If only the width is specified for a resize operation, * GraphicsMagick requires the format * -resize 10x * while ImageMagick requires the format - * -resize 10 + * -resize 10 * */ -var assert = require('assert') +const assert = require('assert') +const path = require('path'); module.exports = function (_, dir, finish, gm) { - if (!gm.integration) return finish(); - - var src = dir + '/originalSideways.jpg'; - var dst = dir + '/originalSideways10x.jpg'; + if (!gm.integration) return finish(); + + var src = path.join(dir, 'originalSideways.jpg'); + var dst = path.join(dir, 'originalSideways10x.jpg'); gm(src).resize(10).write(dst, function(err) { gm(dst).size(function(err, size) { diff --git a/test/393.js b/test/393.js index b339b0a1..790ac043 100644 --- a/test/393.js +++ b/test/393.js @@ -1,13 +1,11 @@ -'use strict'; - -var assert = require('assert'); -var fs = require('fs'); -var path = require('path'); +const assert = require('assert'); +const fs = require('fs'); +const path = require('path'); module.exports = function (_, dir, finish, gm) { if (!gm.integration) return finish(); - var imagePath = path.join(__dirname, './fixtures/nyancat.gif'); + var imagePath = path.join(__dirname, './fixtures', 'nyancat.gif'); var inputStream = fs.createReadStream(imagePath); gm(inputStream) .identify({ bufferStream: true }, function(err, value) { diff --git a/test/417.js b/test/417.js index d146aaa9..b179bc17 100644 --- a/test/417.js +++ b/test/417.js @@ -1,24 +1,27 @@ -var assert = require('assert') -var fs = require('fs'); -var path = require('path'); +const assert = require('assert') +const fs = require('fs'); +const path = require('path'); module.exports = function (_, dir, finish, gm) { if (!gm.integration) return finish(); - gm(dir + '/original.jpg') - .thumb(150, 40, dir + '/thumb.png', function thumb (err) { - gm(dir + '/thumb.png') + const originalPathName = path.join(dir, 'original.jpg'); + const thumbPathName = path.join(dir, 'thumb.png'); + + gm(originalPathName) + .thumb(150, 40, thumbPathName, function thumb (err) { + gm(thumbPathName) .size(function (err, size) { if (err) return finish(err); assert.equal(142, size.width); assert.equal(40, size.height); - gm(dir + '/original.jpg') - .thumbExact(150, 40, dir + '/thumb.png', function thumb (err) { - gm(dir + '/thumb.png') + gm(originalPathName) + .thumbExact(150, 40, thumbPathName, function thumb (err) { + gm(thumbPathName) .size(function (err, size) { assert.equal(150, size.width); assert.equal(40, size.height); diff --git a/test/422.js b/test/422.js index 583d9698..dfc15f6b 100644 --- a/test/422.js +++ b/test/422.js @@ -1,38 +1,48 @@ -var assert = require('assert'); -var fs = require('fs'); +const fs = require('fs'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { // Same image - GM.compare(dir + '/original.jpg', dir + '/original.png', function(err, same) { + const originalPathName = path.join(dir, 'original.jpg'); + + GM.compare(originalPathName, originalPathName, function(err, same) { if (err) return finish(err); if (!same) return finish(new Error('Compare should be the same!')); // Compare almost similar images for which ImageMagick - // returns a exponent-style floating point number - gm.compare(__dirname + '/fixtures/compare_1.png', __dirname + '/fixtures/compare_2.png', function(err, same, diff) { + // returns an exponent-style floating point number + const compare1PathName = path.join(__dirname, 'fixtures', 'compare_1.png'); + const compare2PathName = path.join(__dirname, 'fixtures', 'compare_2.png'); + + gm.compare(compare1PathName, compare2PathName, function(err, same, diff) { if (err) return finish(err); + if (!same) return finish(new Error('Compare should be the same!')); + + const noisePathName = path.join(dir, 'noise3.png'); // Create a new noisy image - gm.noise(0.3).write(dir + '/noise3.png', function (err) { + gm.noise(0.3).write(noisePathName, function (err) { if (err) return finish(err); - if (!same) return finish(new Error('Compare should be the same!')); var options = { highlightColor: '#fff', highlightStyle: 'XOR', - file: dir + '/diff.png', + file: path.join(dir, 'diff.png'), tolerance: 0.001 }; + const originalPathName = path.join(dir, 'original.jpg'); + // Compare these images and write to a file. - GM.compare(dir + '/original.jpg', dir + '/noise3.png', options, function(err) { + GM.compare(originalPathName, noisePathName, options, function(err) { if (err) return finish(err); - fs.exists(options.file, function(exists) { - if (exists) { - fs.unlink(options.file, finish); - } - else finish(new Error('Diff file does not exist.')); + fs.access(options.file, fs.constants.F_OK, function(err) { + if (err) { + finish(new Error('Diff file does not exist.')); + } else { + fs.unlink(options.file, finish); + } }); }); }); diff --git a/test/429.js b/test/429.js index c6df739a..dd8a7ed5 100644 --- a/test/429.js +++ b/test/429.js @@ -1,10 +1,11 @@ const assert = require('assert'); const fs = require('fs'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - const ico = `${__dirname}/fixtures/test.ico`; + const ico = path.join(__dirname, 'fixtures', 'test.ico'); const buffer = fs.readFileSync(ico); const stream = fs.createReadStream(ico); diff --git a/test/70.js b/test/70.js index 3cf4fe43..32dfc14a 100644 --- a/test/70.js +++ b/test/70.js @@ -1,10 +1,10 @@ -// gm - Copyright Aaron Heckmann (MIT Licensed) -var assert = require('assert') -var times = 16; +const assert = require('assert') +const path = require('path'); -var loading = __dirname + '/fixtures/loading.gif' -var favicon = __dirname + '/fixtures/favicon.png' +var times = 16; +var loading = path.join(__dirname, 'fixtures', 'loading.gif'); +var favicon = path.join(__dirname, 'fixtures', 'favicon.png'); module.exports = function (_, dir, finish, gm) { if (!gm.integration) return finish(); diff --git a/test/78.js b/test/78.js index 60780668..5dd262c3 100644 --- a/test/78.js +++ b/test/78.js @@ -1,19 +1,16 @@ +const assert = require('assert'); +const path = require('path'); -var assert = require('assert') - -module.exports = function (_, dir, finish, gm) { +module.exports = function (_, dir, finish, gm, imageMagick) { if (!gm.integration) return finish(); - var magick = _._options.imageMagick; - var name = magick ? '78-IM' : '78'; - var out = dir + '/' + name; + var name = imageMagick ? '78-IM' : '78'; + var out = path.join(dir, name); _.resize(600, 450, '!').write(out + '.png', function (err) { if (err) return finish(err); - var img = gm(out + '.png'); - if (magick) - img.options({ imageMagick: true }); + var img = gm(out + '.png').options({ imageMagick }); img .crop(70, 70, 100, 100) diff --git a/test/alpha.js b/test/alpha.js index d9fac0f0..161076c3 100644 --- a/test/alpha.js +++ b/test/alpha.js @@ -1,5 +1,6 @@ -var assert = require('assert'); -var async = require('async'); +const assert = require('assert'); +const Async = require('async'); +const path = require('path'); module.exports = function (_, dir, finish, gm, im) { if (!gm.integration) return finish(); @@ -17,25 +18,29 @@ module.exports = function (_, dir, finish, gm, im) { "Shape", "Background" ]; + + const edgePath = path.join(dir, 'edge.png'); + const failPath = path.join(dir, 'alpha_fail.png'); + // alpha not supported by GM so only test IM if (!im) { assert.throws(function() { - gm(dir + '/edge.png') - .alpha( alphaTypes.pop() ).write(dir+'/alpha_fail.png'); - + gm(edgePath) + .alpha(alphaTypes.pop()) + .write(failPath); }); finish(); } else { - async.eachSeries(alphaTypes,function(alphaType,cb) { - var m = gm(dir + '/edge.png').options({imageMagick: im}).alpha( alphaType ); - var args = m.args(); - assert.equal('convert', args[0]); - assert.equal('-alpha', args[2]); - assert.equal(alphaType, args[3]); + Async.eachSeries(alphaTypes, function(alphaType,cb) { + var m = gm(edgePath).options({imageMagick: im}).alpha( alphaType ); + var args = m.args(); + assert.equal('convert', args[0]); + assert.equal('-alpha', args[2]); + assert.equal(alphaType, args[3]); - m.write( dir + '/alpha_' + alphaType + '.png', cb); - - },finish); -} + const writePath = path.join(dir, `alpha_${alphaType}.png`); + m.write(writePath, cb); + }, finish); + } } diff --git a/test/append.js b/test/append.js index 7fcadab9..1976b202 100644 --- a/test/append.js +++ b/test/append.js @@ -1,14 +1,17 @@ -var assert = require('assert') +const assert = require('assert') +const path = require('path'); module.exports = function (_, dir, finish, gm) { - var out = require('path').resolve(dir + '/append.jpg'); + const out = path.resolve(dir, 'append.jpg'); + const lostPath = path.join(dir, 'lost.png'); + const originalPath = path.join(dir, 'original.jpg'); try { require('fs').unlinkSync(out); } catch (_) {} - var m = gm(dir + '/lost.png') - .append(dir + '/original.jpg', dir + '/original.jpg') + var m = gm(lostPath) + .append(originalPath, originalPath) .append() .background('#222') @@ -16,14 +19,14 @@ module.exports = function (_, dir, finish, gm) { assert.equal('convert', args[0]); assert.equal('-background',args[1]); assert.equal('#222',args[2]); - assert.ok(/examples\/imgs\/lost\.png$/.test(args[3])); - assert.ok(/examples\/imgs\/original\.jpg$/,args[4]); - assert.ok(/examples\/imgs\/original\.jpg$/,args[5]); + assert.ok(/lost\.png$/.test(args[3])); + assert.ok(/original\.jpg$/,args[4]); + assert.ok(/original\.jpg$/,args[5]); assert.equal('-append',args[6]); assert.equal('-',args[7]); if (!gm.integration) { - return horizontal(dir, finish, gm); + return horizontal({ dir, finish, gm, originalPath, lostPath }); } m.write(out, function (err) { @@ -33,21 +36,20 @@ module.exports = function (_, dir, finish, gm) { assert.equal(460, size.width); assert.equal(435, size.height); - horizontal(dir, finish, gm); + horizontal({ dir, finish, gm, originalPath, lostPath }); }) }); } -function horizontal (dir, finish, gm) { - var out = require('path').resolve(dir + '/appendHorizontal.jpg'); +function horizontal ({ dir, finish, gm, originalPath, lostPath }) { + var out = path.resolve(dir, 'appendHorizontal.jpg'); - var m = gm(dir + '/original.jpg') - .append(dir + '/lost.png', true); + var m = gm(originalPath).append(lostPath, true); var args = m.args(); assert.equal('convert', args[0]); - assert.ok(/examples\/imgs\/original\.jpg$/.test(args[1])); - assert.ok(/examples\/imgs\/lost\.png$/.test(args[2])); + assert.ok(/original\.jpg$/.test(args[1])); + assert.ok(/lost\.png$/.test(args[2])); assert.equal('+append',args[3]); assert.equal('-',args[4]); diff --git a/test/arc.js b/test/arc.js index 5f54bbb2..f5cda926 100644 --- a/test/arc.js +++ b/test/arc.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert') +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -22,11 +22,11 @@ module.exports = function (gm, dir, finish, GM) { assert.equal('-draw', args[10]); assert.equal('arc 80,10 90,20 0,180', args[11]); - if (!GM.integration) - return finish(); + if (!GM.integration) return finish(); + + const arcPath = path.join(dir, 'arc.png'); - m - .write(dir + '/arc.png', function arc (err) { + m.write(arcPath, function arc (err) { finish(err); }); } diff --git a/test/autoOrient.js b/test/autoOrient.js index 2a9806d2..c78bb405 100644 --- a/test/autoOrient.js +++ b/test/autoOrient.js @@ -1,22 +1,20 @@ - -// gm - Copyright Aaron Heckmann (MIT Licensed) - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (_, dir, finish, gm) { if (!gm.integration) return finish(); - var filename = dir + '/autoOrient.jpg'; + const sidewaysPath = path.join(dir, 'originalSideways.jpg'); - gm(dir + '/originalSideways.jpg').identify(function (err, o) { + gm(sidewaysPath).identify(function (err, o) { if (err) return finish(err); assert.equal('155x460', o.Geometry); // this image is sideways, but may be auto-oriented by modern OS's // try opening it in a browser to see its true orientation - gm(dir + '/originalSideways.jpg') + gm(sidewaysPath) .autoOrient() .stream(function (err, stream) { if (err) return finish(err); diff --git a/test/autoOrientAll.js b/test/autoOrientAll.js index 3fb07a0f..aebb24a8 100644 --- a/test/autoOrientAll.js +++ b/test/autoOrientAll.js @@ -1,13 +1,9 @@ - -// gm - Copyright Aaron Heckmann (MIT Licensed) - -var assert = require('assert'), - fs = require('fs'), - os = require('os'); +const assert = require('assert'); +const fs = require('fs'); +const path = require('path'); module.exports = function (_, dir, finish, gm) { - if (!gm.integration) - return finish(); + if (!gm.integration) return finish(); var beforeValues = { 'Landscape_1.jpg': ['TopLeft', 1, '600x450'], @@ -47,7 +43,9 @@ module.exports = function (_, dir, finish, gm) { 'Portrait_8.jpg': '450x600' }; - fs.readdir(dir + '/orientation/', function(err, files) { + const orientationDir = path.join(dir, 'orientation'); + + fs.readdir(orientationDir, function(err, files) { if (err) return finish(err); var originalFiles = files.filter(function(file) { @@ -63,9 +61,9 @@ module.exports = function (_, dir, finish, gm) { function test (filename) { if (!filename) return finish(); - var fileToAutoOrient = dir + '/orientation/' + filename; - var newFilename = fileToAutoOrient + '.oriented.jpg'; - var constant = fileToAutoOrient + '.correct.jpg'; + const fileToAutoOrient = path.join(orientationDir, filename); + const newFilename = fileToAutoOrient + '.oriented.jpg'; + const constant = fileToAutoOrient + '.correct.jpg'; gm(fileToAutoOrient).orientation(function (err, o) { if (err) return finish(err); diff --git a/test/autoOrientAndThumb.js b/test/autoOrientAndThumb.js index 9e446a7b..618b89b1 100755 --- a/test/autoOrientAndThumb.js +++ b/test/autoOrientAndThumb.js @@ -1,12 +1,12 @@ -var assert = require('assert') -var fs = require('fs') +const assert = require('assert') +const path = require('path'); module.exports = function (_, dir, finish, gm) { if (!gm.integration) return finish(); - var original = dir + '/orientation/Portrait_7.jpg'; - var result = dir + '/autoOrientAndThumb.png'; + var original = path.join(dir, 'orientation', 'Portrait_7.jpg'); + var result = path.join(dir, 'autoOrientAndThumb.png'); size(original, function (err, origSize) { if (err) return finish(err); @@ -29,7 +29,6 @@ module.exports = function (_, dir, finish, gm) { }); }); - function size (file, cb) { gm(file).identify(function (err, data) { if (err) return cb(err); diff --git a/test/autoOrientStream.js b/test/autoOrientStream.js index 8b4ea18f..1502cc7a 100644 --- a/test/autoOrientStream.js +++ b/test/autoOrientStream.js @@ -2,23 +2,25 @@ // gm - Copyright Aaron Heckmann (MIT Licensed) // This is a copy of `autoOrient.js` using streams -var assert = require('assert') -var fs = require('fs') +const assert = require('assert') +const fs = require('fs') +const path = require('path'); module.exports = function (_, dir, finish, gm) { if (!gm.integration) return finish(); - var filename = dir + '/autoOrientStream.jpg'; + const filename = path.join(dir, 'autoOrientStream.jpg'); + const sidewaysPathName = path.join(dir, 'originalSideways.jpg'); - gm(fs.createReadStream(dir + '/originalSideways.jpg')).identify(function (err) { + gm(fs.createReadStream(sidewaysPathName)).identify(function (err) { if (err) return finish(err); assert.equal('155x460', this.data.Geometry); // this image is sideways, but may be auto-oriented by modern OS's // try opening it in a browser to see its true orientation - gm(fs.createReadStream(dir + '/originalSideways.jpg')) + gm(fs.createReadStream(sidewaysPathName)) .autoOrient() .write(filename, function autoOrient (err) { if (err) return finish(err); diff --git a/test/background.js b/test/background.js index da742225..b3f2268c 100644 --- a/test/background.js +++ b/test/background.js @@ -1,4 +1,5 @@ -var assert =require('assert') +const assert =require('assert') +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -19,8 +20,9 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/background.jpg', function (err) { + const backgroundPathName = path.join(dir, 'background.jpg'); + + m.write(backgroundPathName, function (err) { finish(err); }); } diff --git a/test/bezier.js b/test/bezier.js index ceedb1fa..0d400b2e 100644 --- a/test/bezier.js +++ b/test/bezier.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert') +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -26,7 +26,7 @@ module.exports = function (gm, dir, finish, GM) { return finish(); m - .write(dir + '/bezier.png', function bezier (err) { + .write(path.join(dir, 'bezier.png'), function bezier (err) { finish(err); }); } diff --git a/test/bitdepth.js b/test/bitdepth.js index 3ad476e3..b8578210 100644 --- a/test/bitdepth.js +++ b/test/bitdepth.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -14,8 +14,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/bitdepth.png', function bitdepth (err) { + const outpath = path.join(dir, 'bitdepth.png'); + m.write(outpath, function bitdepth (err) { finish(err); }); } diff --git a/test/blur.js b/test/blur.js index 71bfae81..28285835 100644 --- a/test/blur.js +++ b/test/blur.js @@ -1,5 +1,6 @@ -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -14,8 +15,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/blur.png', function blur (err) { + const outpath = path.join(dir, 'blur.png'); + m.write(outpath, function blur (err) { finish(err); }); } diff --git a/test/changeFormat.js b/test/changeFormat.js index 1d8b1545..9974a8c3 100644 --- a/test/changeFormat.js +++ b/test/changeFormat.js @@ -1,12 +1,11 @@ - -// gm - Copyright Aaron Heckmann (MIT Licensed) +const path = require('path'); module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - gm - .write(dir + '/changedformat.png', function changeformat (err) { + const outpath = path.join(dir, 'changedformat.png'); + gm.write(outpath, function changeformat (err) { finish(err); }); } diff --git a/test/charcoal.js b/test/charcoal.js index a6f7105d..14a13ed3 100644 --- a/test/charcoal.js +++ b/test/charcoal.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -14,8 +14,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/charcoal.png', function charcoal (err) { + const outpath = path.join(dir, 'charcoal.png'); + m.write(outpath, function charcoal (err) { finish(err); }); } diff --git a/test/chop.js b/test/chop.js index e6d3a5c5..3a14fb72 100644 --- a/test/chop.js +++ b/test/chop.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -14,8 +14,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/chop.png', function chop (err) { + const outpath = path.join(dir, 'chop.png'); + m.write(outpath, function chop (err) { finish(err); }); } diff --git a/test/circle.js b/test/circle.js index 29c4e72e..9b581c91 100644 --- a/test/circle.js +++ b/test/circle.js @@ -1,8 +1,7 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { - var m = gm .blur(8, 4) .stroke("red", 1) @@ -25,8 +24,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/circle.png', function circle (err) { + const outpath = path.join(dir, 'circle.png'); + m.write(outpath, function circle (err) { finish(err); }); } diff --git a/test/colorize.js b/test/colorize.js index 1e6f5f36..d596607d 100644 --- a/test/colorize.js +++ b/test/colorize.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -14,8 +14,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/colorize.png', function colorize (err) { + const outpath = path.join(dir, 'colorize.png'); + m.write(outpath, function colorize (err) { finish(err); }); } diff --git a/test/colors.js b/test/colors.js index 62af990a..d8c98aa5 100644 --- a/test/colors.js +++ b/test/colors.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -14,8 +14,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/colors.png', function colors (err) { + const outpath = path.join(dir, 'colors.png'); + m.write(outpath, function colors (err) { finish(err); }); } diff --git a/test/comment.js b/test/comment.js index 26789d76..22f798a8 100644 --- a/test/comment.js +++ b/test/comment.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -14,8 +14,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/comment.png', function comment (err) { + const outpath = path.join(dir, 'comment.png'); + m.write(outpath, function comment (err) { finish(err); }); } diff --git a/test/compare.js b/test/compare.js index bdcbda79..13a868e5 100644 --- a/test/compare.js +++ b/test/compare.js @@ -1,36 +1,46 @@ -var assert = require('assert'); -var fs = require('fs'); +const path = require('path'); +const fs = require('fs'); module.exports = function (gm, dir, finish, GM) { // Same image - GM.compare(dir + '/original.jpg', dir + '/original.png', function(err, same) { + const originalJPGFilePath = path.join(dir, 'original.jpg'); + const originalPNGFilePath = path.join(dir, 'original.png'); + + GM.compare(originalJPGFilePath, originalPNGFilePath, function(err, same) { if (err) return finish(err); if (!same) return finish(new Error('Compare should be the same!')); // Compare almost similar images for which ImageMagick // returns a exponent-style floating point number - gm.compare(__dirname + '/fixtures/compare_1.png', __dirname + '/fixtures/compare_2.png', function(err, same, diff) { + const compare1Path = path.join(__dirname, 'fixtures', 'compare_1.png'); + const compare2Path = path.join(__dirname, 'fixtures', 'compare_2.png'); + + gm.compare(compare1Path, compare2Path, function(err, same, diff) { if (err) return finish(err); + if (!same) return finish(new Error('Compare should be the same!')); // Create a new noisy image - gm.noise(0.3).write(dir + '/noise3.png', function (err) { + const noisePath = path.join(dir, 'noise3.png'); + gm.noise(0.3).write(noisePath, function (err) { if (err) return finish(err); - if (!same) return finish(new Error('Compare should be the same!')); var options = { highlightColor: 'yellow', highlightStyle: 'XOR', - file: dir + '/diff.png', + file: path.join(dir, `compare-test-${Date.now()}.png`), tolerance: 0.001 }; // Compare these images and write to a file. - GM.compare(dir + '/original.jpg', dir + '/noise3.png', options, function(err) { + GM.compare(originalJPGFilePath, noisePath, options, function(err) { if (err) return finish(err); - fs.exists(options.file, function(exists) { - if (exists) finish(); - else finish(new Error('Diff file does not exist.')); + fs.access(options.file, fs.constants.F_OK, function(err) { + if (err) { + finish(new Error('Diff file does not exist.')); + } else { + fs.unlink(options.file, () => finish()); + } }); }); }); diff --git a/test/composite.js b/test/composite.js index 6cc278f3..8b47dd5f 100644 --- a/test/composite.js +++ b/test/composite.js @@ -1,20 +1,23 @@ - -var assert = require('assert') +const assert = require('assert') +const path = require('path'); module.exports = function (gm, dir, finish, GM) { - gm.source = __dirname + '/fixtures/compare_1.png'; - var a = gm.composite(__dirname + '/fixtures/favicon.png') + const sourcePath = path.join(__dirname, 'fixtures', 'compare_1.png'); + gm.source = sourcePath; + + const faviconPath = path.join(__dirname, 'fixtures', 'favicon.png'); + const a = gm.composite(faviconPath) - var args = a.args(); + const args = a.args(); assert.equal('composite', args[0]); - assert.equal(__dirname + '/fixtures/favicon.png', args[1]); - assert.equal(__dirname + '/fixtures/compare_1.png', args[2]); + assert.equal(faviconPath, args[1]); + assert.equal(sourcePath, args[2]); if (!GM.integration) return finish(); - a - .write(dir + '/composite.png', function(err) { + const destPath = path.join(dir, 'composite.png'); + a.write(destPath, function(err) { finish(err); }); } diff --git a/test/contrast.js b/test/contrast.js index 70e10c02..a37d8608 100644 --- a/test/contrast.js +++ b/test/contrast.js @@ -1,21 +1,19 @@ - -var assert = require('assert') +const assert = require('assert') +const path = require('path'); module.exports = function (gm, dir, finish, GM) { + const m = gm.contrast(2); - var m = gm - .contrast(2); - - var args = m.args(); + const args = m.args(); assert.equal('convert', args[0]); assert.equal('+contrast', args[2]); assert.equal('+contrast', args[3]); - if (!GM.integration) - return finish(); + if (!GM.integration) return finish(); + + const destPath = path.join(dir, 'contrast.png'); - m - .write(dir + '/contrast.png', function contrast (err) { + m.write(destPath, function contrast (err) { finish(err); }); } diff --git a/test/crop.js b/test/crop.js index f293b3d1..ac11e455 100644 --- a/test/crop.js +++ b/test/crop.js @@ -1,27 +1,25 @@ - -var assert = require('assert') +const assert = require('assert') +const path = require('path'); module.exports = function (gm, dir, finish, GM) { + const m = gm.crop(200, 155, 300, 0); - var m = gm - .crop(200, 155, 300, 0); - - var args = m.args(); + const args = m.args(); assert.equal('convert', args[0]); assert.equal('-crop', args[2]); assert.equal('200x155+300+0', args[3]); - var m2 = GM(dir + '/image.png') - .crop(200, 155, 300, 0, true); + const imagePath = path.join(dir, 'image.png'); + const m2 = GM(imagePath).crop(200, 155, 300, 0, true); - var args2 = m2.args(); + const args2 = m2.args(); assert.equal('200x155+300+0%', args2[3]); if (!GM.integration) return finish(); - m - .write(dir + '/crop.png', function crop (err) { + const destPath = path.join(dir, 'crop.png'); + m.write(destPath, function crop (err) { finish(err); }); } diff --git a/test/cycle.js b/test/cycle.js index b1101b6f..15c67925 100644 --- a/test/cycle.js +++ b/test/cycle.js @@ -1,12 +1,10 @@ - -var assert = require('assert') +const assert = require('assert') +const path = require('path'); module.exports = function (gm, dir, finish, GM) { + const m = gm.cycle(4); - var m = gm - .cycle(4); - - var args = m.args(); + const args = m.args(); assert.equal('convert', args[0]); assert.equal('-cycle', args[2]); assert.equal(4, args[3]); @@ -14,8 +12,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/cycle.png', function cycle (err) { + const destPath = path.join(dir, 'cycle.png'); + m.write(destPath, function cycle (err) { finish(err); }); } diff --git a/test/densityGm.js b/test/densityGm.js index 40c8ed32..9d0af8a7 100644 --- a/test/densityGm.js +++ b/test/densityGm.js @@ -1,17 +1,13 @@ - -var assert = require('assert'); +const assert = require('assert') +const path = require('path'); module.exports = function (gm, dir, finish, GM) { - 'use strict'; - - // a two magic numbers var NUMBER = 100; var NUMBER2 = 200; var g = gm.density(NUMBER, NUMBER2); var gArgs = g.args(); - assert.equal('convert', gArgs[0]); assert.equal('-density', gArgs[1]); assert.equal(NUMBER + 'x' + NUMBER2, gArgs[2]); @@ -22,7 +18,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - g.write(dir + '/density.png', function density (err) { + const destPath = path.join(dir, 'density.png'); + g.write(destPath, function density (err) { finish(err); }); }; diff --git a/test/index.js b/test/index.js index c18d9f1e..f614e7eb 100644 --- a/test/index.js +++ b/test/index.js @@ -1,11 +1,10 @@ +const cp = require('child_process'); +const path = require('path'); +const Async = require('async'); +const dir = path.join(__dirname, '..', 'examples', 'imgs'); +const gm = require('..'); +const fs = require('fs'); -// gm - Copyright Aaron Heckmann (MIT Licensed) - -var async = require('async'); -var dir = __dirname + '/../examples/imgs'; -var gm = require('../'); -var assert = require('assert'); -var fs = require('fs'); var only = process.argv.slice(2); gm.integration = !! ~process.argv.indexOf('--integration'); if (gm.integration) only.shift(); @@ -17,17 +16,19 @@ function filter (file) { if ('index.js' === file) return false; if (only.length && !~only.indexOf(file)) return false; - var filename = __dirname + '/' + file; + var filename = path.join(__dirname, file); if (!fs.statSync(filename).isFile()) return false; return true; } +const originalPathName = path.join(dir, 'original.jpg'); + function test (imageMagick) { if (imageMagick) { - return gm(dir + '/original.jpg').options({ imageMagick }); + return gm(originalPathName).options({ imageMagick }); } - return gm(dir + '/original.jpg'); + return gm(originalPathName); } function finish (filename) { @@ -43,9 +44,18 @@ function finish (filename) { } } +function isMagickInstalled() { + try { + cp.execSync('magick -version'); + return true; + } catch (_) { + return false; + } +} + process.stdout.write('\033[?25l'); -var q = async.queue(function (task, callback) { +var q = Async.queue(function (task, callback) { var filename = task.filename; var im = task.imagemagick; @@ -56,34 +66,37 @@ var q = async.queue(function (task, callback) { }, 1); q.drain = function(){ - -process.stdout.write('\033[?25h'); - process.stdout.write('\033[2K'); - process.stdout.write('\033[0G'); - console.error("\n\u001B[32mAll tests passed\u001B[0m"); + process.stdout.write('\033[?25h'); + process.stdout.write('\033[2K'); + process.stdout.write('\033[0G'); + console.error("\n\u001B[32mAll tests passed\u001B[0m"); }; files = files.map(function (file) { - return __dirname + '/' + file -}) + return path.join(__dirname, file); +}); -files.forEach(function (file) { +files.forEach(function (filename) { q.push({ imagemagick: false, - filename: file + filename }) -}) +}); -files.forEach(function (file) { +files.forEach(function (filename) { q.push({ imagemagick: true, - filename: file - }) -}) - -files.forEach(function (file) { - q.push({ - imagemagick: '7+', - filename: file + filename }) -}) +}); + +if (isMagickInstalled()) { + console.log('magick is installed'); + + files.forEach(function (filename) { + q.push({ + imagemagick: '7+', + filename + }) + }); +} \ No newline at end of file From ad6097fce8db478eecdb781ebcb8bf054349cb83 Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Mon, 19 Sep 2022 22:03:20 -0700 Subject: [PATCH 59/64] tests; report when no matching tests found --- test/densityGm.js | 9 ++++----- test/densityIm.js | 20 +++++++------------- test/despeckle.js | 12 +++++------- test/dispose.js | 14 +++++++++----- test/dither.js | 7 ++++--- test/edge.js | 8 ++++---- test/ellipse.js | 8 ++++---- test/emboss.js | 8 ++++---- test/enhance.js | 8 ++++---- test/equalize.js | 8 ++++---- test/extent.js | 7 ++++--- test/flatten.js | 10 ++++++---- test/flip.js | 8 ++++---- test/flop.js | 8 ++++---- test/fromBuffer.js | 9 +++++---- test/gamma.js | 8 ++++---- test/getterColor.js | 7 ++++--- test/getterFormatGIF.js | 7 ++++--- test/getterIdentify.js | 17 +++++++++++------ test/getterIptc.js | 7 ++++--- test/getterMultipleIptc.js | 7 ++++--- test/getterSize.js | 16 ++++++++++------ test/gh-17.js | 8 ++++---- test/gifFrame.js | 10 +++++----- test/gifFrameIdentify.js | 8 ++++---- test/gifFrameStream.js | 13 +++++++------ test/gravity.js | 7 ++++--- test/implode.js | 8 ++++---- test/index.js | 7 +++++-- test/inputIs.js | 12 ++++++------ test/interlace.js | 8 ++++---- test/label.js | 8 ++++---- test/limit.js | 8 ++++---- test/line.js | 8 ++++---- test/lower.js | 8 ++++---- test/magnify.js | 8 ++++---- test/median.js | 8 ++++---- test/minify.js | 8 ++++---- test/minifyIM.js | 9 +++++---- test/modulate.js | 8 ++++---- test/monochrome.js | 8 ++++---- test/montage.js | 20 ++++++++++++-------- test/morph-more.js | 8 ++++++-- test/morph.js | 9 ++++----- test/negative.js | 8 ++++---- test/new.js | 8 ++++---- test/newImage.js | 10 ++++++---- test/noise1.js | 8 ++++---- test/noise2.js | 9 +++++---- test/options.js | 15 ++++++++------- test/paint.js | 8 ++++---- test/polygon.js | 8 ++++---- test/polyline.js | 8 ++++---- test/quality.js | 8 ++++---- test/raise.js | 8 ++++---- test/rectangle.js | 8 ++++---- test/region.js | 8 ++++---- test/repagePlus.js | 7 ++++--- test/resample.js | 8 ++++---- test/resize.js | 8 ++++---- test/resizeAndAutoOrientFromBuffer.js | 9 +++++---- test/resizeBuffer.js | 9 +++++---- test/resizeWrong.js | 7 +++---- test/roll.js | 8 ++++---- test/rotate.js | 10 +++++----- test/scale.js | 8 ++++---- test/selectFrame.js | 7 ++++--- test/sepia.js | 8 ++++---- test/setFormat.js | 8 ++++---- test/sharpen.js | 8 ++++---- test/solarize.js | 8 ++++---- test/spread.js | 8 ++++---- test/streamIn.js | 15 ++++++++------- test/streamInGetter.js | 11 ++++++----- test/streamInOut.js | 10 ++++++---- test/streamOut.js | 10 ++++++---- test/streamOutFormat.js | 22 +++++++--------------- test/strip.js | 8 ++++---- test/subclass.js | 10 ++++++---- test/swirl.js | 8 ++++---- test/text.js | 8 ++++---- test/thumb.js | 8 ++++---- test/thumbnail.js | 8 ++++---- test/timeout.js | 14 ++++++++------ test/webp.js | 20 +++++++++++--------- 85 files changed, 418 insertions(+), 381 deletions(-) diff --git a/test/densityGm.js b/test/densityGm.js index 9d0af8a7..89c651bb 100644 --- a/test/densityGm.js +++ b/test/densityGm.js @@ -2,6 +2,8 @@ const assert = require('assert') const path = require('path'); module.exports = function (gm, dir, finish, GM) { + const isImageMagickTest = !!gm._options.imageMagick; + var NUMBER = 100; var NUMBER2 = 200; @@ -12,11 +14,8 @@ module.exports = function (gm, dir, finish, GM) { assert.equal('-density', gArgs[1]); assert.equal(NUMBER + 'x' + NUMBER2, gArgs[2]); - if (gm._options.imageMagick) - return finish(); - - if (!GM.integration) - return finish(); + if (isImageMagickTest) return finish(); + if (!GM.integration) return finish(); const destPath = path.join(dir, 'density.png'); g.write(destPath, function density (err) { diff --git a/test/densityIm.js b/test/densityIm.js index 82dd0624..27e58a6b 100644 --- a/test/densityIm.js +++ b/test/densityIm.js @@ -1,28 +1,22 @@ - -var assert = require('assert'); +const assert = require('assert') +const path = require('path'); module.exports = function (gm, dir, finish, GM) { - 'use strict'; + const isImageMagickTest = !!gm._options.imageMagick; - // a magic number var NUMBER = 100; - - // image magic version var im = gm.options({imageMagick: true}).density(NUMBER); var imArgs = im.args(); - assert.equal('convert', imArgs[0]); assert.equal('-density', imArgs[1]); assert.equal(NUMBER, imArgs[2]); - if (gm._options.imageMagick) - return finish(); - - if (!GM.integration) - return finish(); + if (isImageMagickTest) return finish(); + if (!GM.integration) return finish(); - im.write(dir + '/density.png', function density (err) { + const destPath = path.join(dir, 'density.png'); + im.write(destPath, function density (err) { finish(err); }); }; diff --git a/test/despeckle.js b/test/despeckle.js index e3e9dec3..0d5d67ce 100644 --- a/test/despeckle.js +++ b/test/despeckle.js @@ -1,10 +1,8 @@ - -var assert = require('assert') +const assert = require('assert') +const path = require('path'); module.exports = function (gm, dir, finish, GM) { - - var m = gm - .despeckle(); + var m = gm.despeckle(); var args = m.args(); assert.equal('convert', args[0]); @@ -13,8 +11,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/despeckle.png', function despeckle (err) { + const destPath = path.join(dir, 'despeckle.png'); + m.write(destPath, function despeckle (err) { finish(err); }); } diff --git a/test/dispose.js b/test/dispose.js index b2187649..ec7cc726 100644 --- a/test/dispose.js +++ b/test/dispose.js @@ -1,4 +1,5 @@ -var assert = require('assert'); +const assert = require('assert') +const path = require('path'); module.exports = function (img, dir, finish, gm) { var EventEmitter = require('events').EventEmitter; @@ -24,8 +25,11 @@ module.exports = function (img, dir, finish, gm) { return finish(); } - gm(dir + '/photo.JPG').options({ disposers: [ disposer ]}) - .thumb(1000, 1000, dir + '/dispose.png', function (err) { + const photoPath = path.join(dir, 'photo.JPG'); + const disposePath = path.join(dir, 'dispose.png'); + + gm(photoPath).options({ disposers: [ disposer ]}) + .thumb(1000, 1000, disposePath, function (err) { assert.ok(err, "Expecting a disposed error"); }); @@ -34,8 +38,8 @@ module.exports = function (img, dir, finish, gm) { noDispose(); function noDispose() { - gm(dir + '/photo.JPG').options({ disposers: [ disposer ]}) - .thumb(1000, 1000, dir + '/dispose.png', function (err) { + gm(photoPath).options({ disposers: [ disposer ]}) + .thumb(1000, 1000, disposePath, function (err) { finish(err); }); emitter.emit('disposeOK'); diff --git a/test/dither.js b/test/dither.js index 97ad31ff..ca53a179 100644 --- a/test/dither.js +++ b/test/dither.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert') +const path = require('path'); module.exports = function (gm, dir, finish, GM) { if (gm._options.imageMagick) @@ -15,7 +15,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - g.write(dir + '/dither.png', function dither (err) { + const destPath = path.join(dir, 'dither.png'); + g.write(destPath, function dither (err) { finish(err); }); } diff --git a/test/edge.js b/test/edge.js index 1c642000..22f04ebf 100644 --- a/test/edge.js +++ b/test/edge.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert') +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -13,8 +13,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/edge.png', function edge (err) { + const destPath = path.join(dir, 'edge.png'); + m.write(destPath, function edge (err) { finish(err); }); } diff --git a/test/ellipse.js b/test/ellipse.js index 8f5a34b7..60bd6d15 100644 --- a/test/ellipse.js +++ b/test/ellipse.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert') +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -22,8 +22,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/ellipse.png', function ellipse (err) { + const destPath = path.join(dir, 'ellipse.png'); + m.write(destPath, function ellipse (err) { finish(err); }); } diff --git a/test/emboss.js b/test/emboss.js index 287d652a..1a831afd 100644 --- a/test/emboss.js +++ b/test/emboss.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert') +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -14,8 +14,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/emboss.png', function emboss (err) { + const destPath = path.join(dir, 'emboss.png'); + m.write(destPath, function emboss (err) { finish(err); }); } diff --git a/test/enhance.js b/test/enhance.js index 2e3d8845..3f9a285e 100644 --- a/test/enhance.js +++ b/test/enhance.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert') +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -13,8 +13,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/enhance.png', function enhance (err) { + const destPath = path.join(dir, 'enhance.png'); + m.write(destPath, function enhance (err) { finish(err); }); } diff --git a/test/equalize.js b/test/equalize.js index f127cc74..e8c506c3 100644 --- a/test/equalize.js +++ b/test/equalize.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert') +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -13,8 +13,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/equalize.png', function equalize (err) { + const destPath = path.join(dir, 'equalize.png'); + m.write(destPath, function equalize (err) { finish(err); }); } diff --git a/test/extent.js b/test/extent.js index 70ef12a9..2c8a0daa 100644 --- a/test/extent.js +++ b/test/extent.js @@ -1,4 +1,5 @@ -var assert = require('assert') +const assert = require('assert') +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -16,8 +17,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/extent.png', function resize (err) { + const destPath = path.join(dir, 'extent.png'); + m.write(destPath, function resize (err) { finish(err); }); } diff --git a/test/flatten.js b/test/flatten.js index de5c5332..d093bd19 100644 --- a/test/flatten.js +++ b/test/flatten.js @@ -1,4 +1,5 @@ -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (img, dir, finish, gm) { // graphicsmagick considers PSD broken @@ -7,7 +8,8 @@ module.exports = function (img, dir, finish, gm) { return finish(); } - var m = gm(dir + '/layers.psd') + const layersPath = path.join(dir, 'layers.psd'); + var m = gm(layersPath) .options({ imageMagick: true }) .flatten(); @@ -18,8 +20,8 @@ module.exports = function (img, dir, finish, gm) { if (!gm.integration) return finish(); - m - .write(dir + '/unlayered.jpg', function (err) { + const destPath = path.join(dir, 'unlayered.jpg'); + m.write(destPath, function (err) { finish(err); }); } diff --git a/test/flip.js b/test/flip.js index d480d555..f440132a 100644 --- a/test/flip.js +++ b/test/flip.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -13,8 +13,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/flip.png', function flip (err) { + const destPath = path.join(dir, 'flip.png'); + m.write(destPath, function flip (err) { finish(err); }); } diff --git a/test/flop.js b/test/flop.js index 99e7975d..91c49b41 100644 --- a/test/flop.js +++ b/test/flop.js @@ -1,5 +1,5 @@ - -var assert =require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -13,8 +13,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/flop.png', function flop (err) { + const destPath = path.join(dir, 'flop.png'); + m.write(destPath, function flop (err) { finish(err); }); } diff --git a/test/fromBuffer.js b/test/fromBuffer.js index 7047f8fb..1bb5d6db 100644 --- a/test/fromBuffer.js +++ b/test/fromBuffer.js @@ -1,10 +1,11 @@ -var assert = require('assert') -var fs = require('fs') +const assert = require('assert'); +const path = require('path'); +const fs = require('fs') module.exports = function (_, dir, finish, gm) { - var original = dir + '/original.jpg'; - var result = dir + '/fromBuffer.png'; + const original = path.join(dir, 'original.jpg'); + const result = path.join(dir, 'fromBuffer.png'); var buf = fs.readFileSync(original); diff --git a/test/gamma.js b/test/gamma.js index 95b1fe24..61d3adf5 100644 --- a/test/gamma.js +++ b/test/gamma.js @@ -1,5 +1,5 @@ - -var assert =require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -14,8 +14,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/gamma.png', function gamma (err) { + const destPath = path.join(dir, 'gamma.png'); + m.write(destPath, function gamma (err) { finish(err); }); } diff --git a/test/getterColor.js b/test/getterColor.js index 511f197d..9f95a5a6 100644 --- a/test/getterColor.js +++ b/test/getterColor.js @@ -1,11 +1,12 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (_, dir, finish, gm) { if (!gm.integration) return finish(); - gm(dir + '/blue.gif').color(function (err, color) { + const destPath = path.join(dir, 'blue.gif'); + gm(destPath).color(function (err, color) { if (err) return finish(err); assert.equal(1, color) diff --git a/test/getterFormatGIF.js b/test/getterFormatGIF.js index e11895be..0fd6dafd 100644 --- a/test/getterFormatGIF.js +++ b/test/getterFormatGIF.js @@ -1,11 +1,12 @@ - -var assert = require('assert'); +const assert = require('assert'); +const path = require('path'); module.exports = function (_, dir, finish, gm) { if (!gm.integration) return finish(); - gm(dir + '/original.gif') + const destPath = path.join(dir, 'original.gif'); + gm(destPath) .format(function (err, type) { if (err) return finish(err); diff --git a/test/getterIdentify.js b/test/getterIdentify.js index 08a62f57..23d9dfbc 100755 --- a/test/getterIdentify.js +++ b/test/getterIdentify.js @@ -1,6 +1,6 @@ - -var assert = require('assert') -var os = require('os') +const assert = require('assert'); +const path = require('path'); +const os = require('os') var isLinux = os.platform() === 'linux' // Be more lax with the errors if we're on linux @@ -12,8 +12,10 @@ module.exports = function (_, dir, finish, gm) { var im = _._options.imageMagick; - var test = gm(dir + '/photo.JPG'); + const photoPath = path.join(dir, 'photo.JPG'); + var test = gm(photoPath); if (im) test.options({ imageMagick: true }); + test.identify(function (err) { if (err) return finish(err); @@ -64,8 +66,10 @@ module.exports = function (_, dir, finish, gm) { }); function gif (callback) { - var test = gm(dir + '/blue.gif'); + const bluePath = path.join(dir, 'blue.gif'); + var test = gm(bluePath); if (im) test.options({ imageMagick: true }); + test.identify(function (err) { if (err) return finish(err); @@ -99,7 +103,8 @@ module.exports = function (_, dir, finish, gm) { } function pattern () { - var test = gm(dir + '/blue.gif'); + const bluePath = path.join(dir, 'blue.gif'); + var test = gm(bluePath); var format = '%f: %m, %wx%h'; var value = 'blue.gif: GIF, 100x200'; diff --git a/test/getterIptc.js b/test/getterIptc.js index 7d66b13a..73cc6193 100644 --- a/test/getterIptc.js +++ b/test/getterIptc.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (_, dir, finish, gm) { if (!gm.integration) @@ -7,7 +7,8 @@ module.exports = function (_, dir, finish, gm) { var im = _._options.imageMagick; - var test = gm(__dirname + '/fixtures/iptc.jpg'); + const iptcPath = path.join(__dirname, 'fixtures', 'iptc.jpg'); + var test = gm(iptcPath); if (im) test.options({ imageMagick: true }); test.identify(function (err) { diff --git a/test/getterMultipleIptc.js b/test/getterMultipleIptc.js index 9ad735dc..f197b17b 100644 --- a/test/getterMultipleIptc.js +++ b/test/getterMultipleIptc.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (_, dir, finish, gm) { if (!gm.integration) @@ -7,7 +7,8 @@ module.exports = function (_, dir, finish, gm) { var im = _._options.imageMagick; - var test = gm(__dirname + '/fixtures/iptc-multiple.jpg'); + const iptcPath = path.join(__dirname, 'fixtures', 'iptc-multiple.jpg'); + var test = gm(iptcPath); if (im) test.options({ imageMagick: true }); test.identify(function (err) { diff --git a/test/getterSize.js b/test/getterSize.js index 52c673d0..422d6ebd 100644 --- a/test/getterSize.js +++ b/test/getterSize.js @@ -1,5 +1,5 @@ - -var assert = require('assert'); +const assert = require('assert'); +const path = require('path'); module.exports = function (_, dir, finish, gm) { if (!gm.integration) @@ -16,19 +16,22 @@ module.exports = function (_, dir, finish, gm) { }) function sizeJPEG(done) { - gm(dir + '/original.jpg') + const originalPath = path.join(dir, 'original.jpg'); + gm(originalPath) .size(function gettersize (err, size) { if (err) return done(err); assert.equal(size.width, 460); assert.equal(size.height, 155); - gm(dir + '/identifyParseErr.jpg').size(done); + const identifyParseErrPath = path.join(dir, 'identifyParseErr.jpg'); + gm(identifyParseErrPath).size(done); }); } function sizeGIF(done) { - gm(dir + '/original.gif') + const originalGifPath = path.join(dir, 'original.gif'); + gm(originalGifPath) .size(function (err, size) { if (err) return done(err); @@ -40,7 +43,8 @@ module.exports = function (_, dir, finish, gm) { } function sizePNG(done) { - gm(dir + '/original.png') + const originalPngPath = path.join(dir, 'original.png'); + gm(originalPngPath) .size(function (err, size) { if (err) return done(err); diff --git a/test/gh-17.js b/test/gh-17.js index ce6e9181..ebb0c40c 100644 --- a/test/gh-17.js +++ b/test/gh-17.js @@ -1,5 +1,5 @@ - -var assert =require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { var m = gm @@ -16,8 +16,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/cropresize.png', function crop (err) { + const destPath = path.join(dir, 'cropresize.png'); + m.write(destPath, function crop (err) { finish(err); }); } diff --git a/test/gifFrame.js b/test/gifFrame.js index 041c6c63..d67d3b38 100644 --- a/test/gifFrame.js +++ b/test/gifFrame.js @@ -1,13 +1,13 @@ - -var fs = require('fs'); -var assert =require('assert') +const path = require('path'); module.exports = function (_, dir, finish, gm) { if (!gm.integration) return finish(); - gm(dir + '/original.gif[0]') - .write(dir + '/gifFrame.jpg', function gifFrame (err){ + const originalGifPath = path.join(dir, 'original.gif[0]'); + const gifFramePath = path.join(dir, 'gifFrame.jpg'); + gm(originalGifPath) + .write(gifFramePath, function gifFrame (err){ finish(err); }); } diff --git a/test/gifFrameIdentify.js b/test/gifFrameIdentify.js index b2f46358..3e16ed1b 100644 --- a/test/gifFrameIdentify.js +++ b/test/gifFrameIdentify.js @@ -1,9 +1,9 @@ - -var assert = require('assert') -var fs = require('fs'); +const assert = require('assert') +const path = require('path'); module.exports = function (_, dir, finish, gm) { - var m = gm(dir + '/original.gif[0]') + const originalGifPath = path.join(dir, 'original.gif[0]'); + var m = gm(originalGifPath); if (!gm.integration) return finish(); diff --git a/test/gifFrameStream.js b/test/gifFrameStream.js index 5e1d9122..90f773a9 100644 --- a/test/gifFrameStream.js +++ b/test/gifFrameStream.js @@ -1,9 +1,10 @@ - -var assert = require('assert') -var fs = require('fs'); +const assert = require('assert') +const path = require('path'); +const fs = require('fs'); module.exports = function (_, dir, finish, gm) { - var m = gm(fs.createReadStream(dir + '/original.gif'), "original.gif[0]") + const originalGifPath = path.join(dir, 'original.gif'); + var m = gm(fs.createReadStream(originalGifPath), "original.gif[0]") var args = m.args(); assert.equal('convert', args[0]); @@ -12,8 +13,8 @@ module.exports = function (_, dir, finish, gm) { if (!gm.integration) return finish(); - m - .write(dir + '/gifFrameStream.jpg', function gifFrame (err){ + const destPath = path.join(dir, 'gifFrameStream.jpg'); + m.write(destPath, function gifFrame (err){ finish(err); }); } diff --git a/test/gravity.js b/test/gravity.js index 89515d8f..20dc69e1 100644 --- a/test/gravity.js +++ b/test/gravity.js @@ -1,4 +1,5 @@ -var assert = require('assert') +const assert = require('assert') +const path = require('path'); module.exports = function (img, dir, finish, gm) { var changed = gm('whatever.png').gravity("Souths") @@ -24,8 +25,8 @@ module.exports = function (img, dir, finish, gm) { if (!gm.integration) return finish(); - m - .write(dir + '/gravity.png', function resize (err) { + const destPath = path.join(dir, 'gravity.png'); + m.write(destPath, function resize (err) { finish(err); }); } diff --git a/test/implode.js b/test/implode.js index 1b8577cc..1681220d 100644 --- a/test/implode.js +++ b/test/implode.js @@ -1,5 +1,5 @@ - -var assert =require('assert') +const assert = require('assert') +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -13,8 +13,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/implode.png', function implode (err) { + const destPath = path.join(dir, 'implode.png'); + m.write(destPath, function implode (err) { finish(err); }); } diff --git a/test/index.js b/test/index.js index f614e7eb..2725c0ec 100644 --- a/test/index.js +++ b/test/index.js @@ -5,11 +5,14 @@ const dir = path.join(__dirname, '..', 'examples', 'imgs'); const gm = require('..'); const fs = require('fs'); -var only = process.argv.slice(2); +const only = process.argv.slice(2); gm.integration = !! ~process.argv.indexOf('--integration'); if (gm.integration) only.shift(); -var files = fs.readdirSync(__dirname).filter(filter); +let files = fs.readdirSync(__dirname).filter(filter); +if (files.length === 0) { + console.log('No tests found matching', only); +} function filter (file) { if (!/\.js$/.test(file)) return false; diff --git a/test/inputIs.js b/test/inputIs.js index 37aecf7a..abb4708b 100644 --- a/test/inputIs.js +++ b/test/inputIs.js @@ -1,13 +1,12 @@ - -// gm - Copyright Aaron Heckmann (MIT Licensed) - -var assert = require('assert') +const assert = require('assert') +const path = require('path'); module.exports = function (_, dir, finish, gm) { var err; try { - var gif = gm('/path/to/blah.gif'); + const blahPath = path.join('path', 'to', 'blah.gif') ; + var gif = gm(blahPath); assert.equal(true, gif.inputIs('gif')); assert.equal(false, gif.inputIs('jpg')); assert.equal(false, gif.inputIs('crazy')); @@ -17,7 +16,8 @@ module.exports = function (_, dir, finish, gm) { assert.equal(false, png.inputIs('gif')); assert.equal(false, png.inputIs('tif')); - var jpg = gm('super/duper.jpeg'); + const jpgPath = path.join('super', 'duper.jpeg') + var jpg = gm(jpgPath); assert.equal(true, jpg.inputIs('jpg')); assert.equal(true, jpg.inputIs('jpeg')); assert.equal(false, jpg.inputIs('gif')); diff --git a/test/interlace.js b/test/interlace.js index 2239831e..cbbc4296 100644 --- a/test/interlace.js +++ b/test/interlace.js @@ -1,5 +1,5 @@ - -var assert =require('assert') +const assert = require('assert') +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -13,8 +13,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/edge.png', function edge (err) { + const destPath = path.join(dir, 'edge.png'); + m.write(destPath, function edge (err) { finish(err); }); } diff --git a/test/label.js b/test/label.js index b23e2ca9..52138287 100644 --- a/test/label.js +++ b/test/label.js @@ -1,5 +1,5 @@ - -var assert =require('assert') +const assert = require('assert') +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -14,8 +14,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/label.png', function label (err) { + const destPath = path.join(dir, 'label.png'); + m.write(destPath, function label (err) { finish(err); }); } diff --git a/test/limit.js b/test/limit.js index b725d5f0..ff7a99f8 100644 --- a/test/limit.js +++ b/test/limit.js @@ -1,5 +1,5 @@ - -var assert =require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -19,8 +19,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/limit.png', function limit (err) { + const destPath = path.join(dir, 'limit.png'); + m.write(destPath, function limit (err) { finish(err); }); } diff --git a/test/line.js b/test/line.js index bfba6f92..635e5cde 100644 --- a/test/line.js +++ b/test/line.js @@ -1,5 +1,5 @@ - -var assert =require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -21,8 +21,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/line.png', function line (err) { + const destPath = path.join(dir, 'line.png'); + m.write(destPath, function line (err) { finish(err); }); } diff --git a/test/lower.js b/test/lower.js index 230ca55d..972b8e73 100644 --- a/test/lower.js +++ b/test/lower.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -14,8 +14,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/lower.png', function lower (err) { + const destPath = path.join(dir, 'lower.png'); + m.write(destPath, function lower (err) { finish(err); }); } diff --git a/test/magnify.js b/test/magnify.js index 1fbb4be1..4a150cce 100644 --- a/test/magnify.js +++ b/test/magnify.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -17,8 +17,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/magnify.png', function magnify (err) { + const destPath = path.join(dir, 'magnify.png'); + m.write(destPath, function magnify (err) { finish(err); }); } diff --git a/test/median.js b/test/median.js index e6a90389..7445df17 100644 --- a/test/median.js +++ b/test/median.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -14,8 +14,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/median.png', function media (err) { + const destPath = path.join(dir, 'median.png'); + m.write(destPath, function media (err) { finish(err); }); } diff --git a/test/minify.js b/test/minify.js index d34ed544..dd6388d1 100644 --- a/test/minify.js +++ b/test/minify.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { if (gm._options.imageMagick) return finish(); @@ -14,8 +14,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/minify.png', function minify (err) { + const destPath = path.join(dir, 'minify.png'); + m.write(destPath, function minify (err) { finish(err); }); } diff --git a/test/minifyIM.js b/test/minifyIM.js index b7307962..d498a657 100644 --- a/test/minifyIM.js +++ b/test/minifyIM.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { var m = gm.minify(); @@ -11,11 +11,12 @@ module.exports = function (gm, dir, finish, GM) { if(gm._options.imageMagick) { assert.throws( function() { - m.write(dir + '/minify.png', function minify (err) { throw err;}) + const destPath = path.join(dir, 'minify.png'); + m.write(destPath, function minify (err) { throw err;}) }, Error ); } - return finish(); + return finish(); } \ No newline at end of file diff --git a/test/modulate.js b/test/modulate.js index 5c5c62e8..02e2cb8a 100644 --- a/test/modulate.js +++ b/test/modulate.js @@ -1,5 +1,5 @@ - -var assert =require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -14,8 +14,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/modulate.png', function modulate (err) { + const destPath = path.join(dir, 'modulate.png'); + m.write(destPath, function modulate (err) { finish(err); }); } diff --git a/test/monochrome.js b/test/monochrome.js index 733f2769..79975fa0 100644 --- a/test/monochrome.js +++ b/test/monochrome.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -13,8 +13,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/monochrome.png', function monochrome (err) { + const destPath = path.join(dir, 'monochrome.png'); + m.write(destPath, function monochrome (err) { finish(err); }); } diff --git a/test/montage.js b/test/montage.js index 8c126712..0b3eef47 100644 --- a/test/montage.js +++ b/test/montage.js @@ -1,20 +1,24 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { - gm.source = __dirname + '/fixtures/compare_1.png'; - var a = gm.montage(__dirname + '/fixtures/favicon.png') + const fixturesPath = path.join(__dirname, 'fixtures'); + const srcPath = path.join(fixturesPath, 'compare_1.png'); + + gm.source = srcPath; + const faviconPath = path.join(fixturesPath, 'favicon.png'); + var a = gm.montage(faviconPath); var args = a.args(); assert.equal('montage', args[0]); - assert.equal(__dirname + '/fixtures/favicon.png', args[1]); - assert.equal(__dirname + '/fixtures/compare_1.png', args[2]); + assert.equal(faviconPath, args[1]); + assert.equal(srcPath, args[2]); if (!GM.integration) return finish(); - a - .write(dir + '/montage.png', function(err) { + const destPath = path.join(dir, 'montage.png'); + a.write(destPath, function(err) { finish(err); }); } diff --git a/test/morph-more.js b/test/morph-more.js index fdbd851d..63a1cc98 100644 --- a/test/morph-more.js +++ b/test/morph-more.js @@ -1,4 +1,4 @@ -var assert = require('assert') +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -7,8 +7,12 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); + const morpherPath = path.join(dir, 'morpher.jpg'); + const originalPath = path.join(dir, 'original.png'); + const morphedPath = path.join(dir, 'morphed2.jpg'); + gm - .morph([dir + '/morpher.jpg', dir + '/original.png'], dir + '/morphed2.jpg', function morph (err) { + .morph([morpherPath, originalPath], morphedPath, function morph (err) { finish(err); }); } diff --git a/test/morph.js b/test/morph.js index 293e0076..e5bccc59 100644 --- a/test/morph.js +++ b/test/morph.js @@ -1,5 +1,4 @@ - -var assert = require('assert') +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -8,10 +7,10 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - // todo, improve this api to allow multiple images + const morpherPath = path.join(dir, 'morpher.jpg'); + const morphedPath = path.join(dir, 'morphed.jpg'); - gm - .morph(dir + '/morpher.jpg', dir + '/morphed.jpg', function morph (err) { + gm.morph(morpherPath, morphedPath, function morph (err) { finish(err); }); } diff --git a/test/negative.js b/test/negative.js index eef2c3b4..1de124fb 100644 --- a/test/negative.js +++ b/test/negative.js @@ -1,5 +1,5 @@ - -var assert =require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -16,8 +16,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/negative.png', function negative (err) { + const destPath = path.join(dir, 'negative.png'); + m.write(destPath, function negative (err) { finish(err); }); } diff --git a/test/new.js b/test/new.js index b0cbedd5..b73ffd20 100644 --- a/test/new.js +++ b/test/new.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (_, dir, finish, gm) { @@ -37,8 +37,8 @@ module.exports = function (_, dir, finish, gm) { if (!gm.integration) return finish(); - m - .write(dir + '/new.png', function New (err){ + const destPath = path.join(dir, 'new.png'); + m.write(destPath, function New (err){ finish(err); }); } diff --git a/test/newImage.js b/test/newImage.js index 80d8f955..f09e3cb7 100644 --- a/test/newImage.js +++ b/test/newImage.js @@ -1,19 +1,21 @@ // https://github.com/aheckmann/gm/issues/127 -var assert = require('assert') -var fs = require('fs') +const path = require('path'); +const fs = require('fs') module.exports = function (_, dir, finish, gm) { if (!gm.integration) return finish(); - createImage().write(dir + '/ignore.me.png', function (err) { + const dest1Path = path.join(dir, 'ignore.me.png'); + createImage().write(dest1Path, function (err) { if (err) return finish(err); createImage().stream(function (err, stdout) { if (err) return finish(err); - stdout.pipe(fs.createWriteStream(dir + '/ignore.me.2.png')) + const dest2Path = path.join(dir, 'ignore.me.2.png'); + stdout.pipe(fs.createWriteStream(dest2Path)) stdout.on('error', finish) stdout.on('end', finish) diff --git a/test/noise1.js b/test/noise1.js index e302678a..9ed9dedc 100644 --- a/test/noise1.js +++ b/test/noise1.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -14,8 +14,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/noise1.png', function noise1 (err) { + const destPath = path.join(dir, 'noise1.png'); + m.write(destPath, function noise1 (err) { finish(err); }); } diff --git a/test/noise2.js b/test/noise2.js index 039c509c..68817248 100644 --- a/test/noise2.js +++ b/test/noise2.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -14,8 +14,9 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/noise2.png', function noise2 (err) { + + const destPath = path.join(dir, 'noise2.png'); + m.write(destPath, function noise2 (err) { finish(err); }); } diff --git a/test/options.js b/test/options.js index aaa8bd80..aa31cb21 100644 --- a/test/options.js +++ b/test/options.js @@ -1,6 +1,6 @@ - -var assert = require('assert') - , fs = require('fs') +const assert = require('assert'); +const path = require('path'); +const fs = require('fs'); module.exports = function (_, dir, finish, gm) { @@ -20,13 +20,14 @@ module.exports = function (_, dir, finish, gm) { assert.equal(true, s2._options.subclassed); assert.equal(undefined, s2._options.setWithMethod); - var writeFile = dir + '/IM-negative' + Math.random() + '.png'; - var imageMagick = gm.subClass({ imageMagick: true }); + const writeFile = path.join(dir, `IM-negative${Math.random()}.png`); + const imageMagick = gm.subClass({ imageMagick: true }); if (!gm.integration) return finish(); - imageMagick(dir + '/photo.JPG') + const photoPath = path.join(dir, 'photo.JPG'); + imageMagick(photoPath) .negative() .write(writeFile, function (err, _1, _2, cmd) { if (err) return finish(err); @@ -40,7 +41,7 @@ module.exports = function (_, dir, finish, gm) { } catch (e) {} /// inline options - gm(dir + '/photo.JPG') + gm(photoPath) .negative() .options({ imageMagick: true }) .write(writeFile, function (err, _1, _2, cmd) { diff --git a/test/paint.js b/test/paint.js index 227b967d..075747e0 100644 --- a/test/paint.js +++ b/test/paint.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -14,8 +14,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/paint.png', function paint (err) { + const destPath = path.join(dir, 'paint.png'); + m.write(destPath, function paint (err) { finish(err); }); } diff --git a/test/polygon.js b/test/polygon.js index 8d56628c..2a7c714b 100644 --- a/test/polygon.js +++ b/test/polygon.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -29,8 +29,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/polygon.png', function polygon (err) { + const destPath = path.join(dir, 'polygon.png'); + m.write(destPath, function polygon (err) { finish(err); }); } diff --git a/test/polyline.js b/test/polyline.js index 91dadae7..487a5451 100644 --- a/test/polyline.js +++ b/test/polyline.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -29,8 +29,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/polyline.png', function polyline (err) { + const destPath = path.join(dir, 'polyline.png'); + m.write(destPath, function polyline (err) { finish(err); }); } diff --git a/test/quality.js b/test/quality.js index b7bc6183..f0f5785a 100644 --- a/test/quality.js +++ b/test/quality.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -14,8 +14,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/quality.png', function quality (err) { + const destPath = path.join(dir, 'quality.png'); + m.write(destPath, function quality (err) { finish(err); }); } diff --git a/test/raise.js b/test/raise.js index e154f432..4d630e12 100644 --- a/test/raise.js +++ b/test/raise.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -14,8 +14,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/raise.png', function raise (err) { + const destPath = path.join(dir, 'raise.png'); + m.write(destPath, function raise (err) { finish(err); }); } diff --git a/test/rectangle.js b/test/rectangle.js index da927e89..00e5b6c2 100644 --- a/test/rectangle.js +++ b/test/rectangle.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -32,8 +32,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/rectangle.png', function rectangle (err) { + const destPath = path.join(dir, 'rectangle.png'); + m.write(destPath, function rectangle (err) { finish(err); }); } diff --git a/test/region.js b/test/region.js index 7c62e3ee..07fa6a20 100644 --- a/test/region.js +++ b/test/region.js @@ -1,5 +1,5 @@ - -var assert =require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -14,8 +14,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/region.png', function region (err) { + const destPath = path.join(dir, 'region.png'); + m.write(destPath, function region (err) { finish(err); }); } diff --git a/test/repagePlus.js b/test/repagePlus.js index a7376ba3..72c587b6 100644 --- a/test/repagePlus.js +++ b/test/repagePlus.js @@ -1,4 +1,5 @@ -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM, im) { @@ -15,8 +16,8 @@ module.exports = function (gm, dir, finish, GM, im) { if (!GM.integration) return finish(); - m - .write(dir + '/repage.png', function blur (err) { + const destPath = path.join(dir, 'repage.png'); + m.write(destPath, function blur (err) { finish(err); }); } diff --git a/test/resample.js b/test/resample.js index f048c2fd..688a12fe 100644 --- a/test/resample.js +++ b/test/resample.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -14,8 +14,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/resample.png', function resample (err) { + const destPath = path.join(dir, 'resample.png'); + m.write(destPath, function resample (err) { finish(err); }); } diff --git a/test/resize.js b/test/resize.js index 7c6b6957..fae94c65 100644 --- a/test/resize.js +++ b/test/resize.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -50,8 +50,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/resize.png', function resize (err) { + const destPath = path.join(dir, 'resize.png'); + m.write(destPath, function resize (err) { finish(err); }); } diff --git a/test/resizeAndAutoOrientFromBuffer.js b/test/resizeAndAutoOrientFromBuffer.js index 522bdf98..04a56443 100755 --- a/test/resizeAndAutoOrientFromBuffer.js +++ b/test/resizeAndAutoOrientFromBuffer.js @@ -1,10 +1,11 @@ -var assert = require('assert') -var fs = require('fs') +const assert = require('assert'); +const path = require('path'); +const fs = require('fs') module.exports = function (_, dir, finish, gm) { - var original = dir + '/orientation/Portrait_7.jpg'; - var result = dir + '/resizeAutoOrientFromBuffer.png'; + const original = path.join(dir, 'orientation', 'Portrait_7.jpg'); + const result = path.join(dir, 'resizeAutoOrientFromBuffer.png'); var buf = fs.readFileSync(original); diff --git a/test/resizeBuffer.js b/test/resizeBuffer.js index 208e91a5..a5087272 100755 --- a/test/resizeBuffer.js +++ b/test/resizeBuffer.js @@ -1,10 +1,11 @@ -var assert = require('assert') -var fs = require('fs') +const assert = require('assert'); +const path = require('path'); +const fs = require('fs') module.exports = function (_, dir, finish, gm) { - var original = dir + '/original.jpg'; - var result = dir + '/resizeFromBuffer.png'; + var original = path.join(dir, 'original.jpg'); + var result = path.join(dir, 'resizeFromBuffer.png'); var buf = fs.readFileSync(original); diff --git a/test/resizeWrong.js b/test/resizeWrong.js index dcf71124..378c783f 100644 --- a/test/resizeWrong.js +++ b/test/resizeWrong.js @@ -1,12 +1,11 @@ -var assert = require('assert') -var fs = require('fs') +const path = require('path'); module.exports = function (_, dir, finish, gm) { if (!gm.integration) return finish(); - var original = dir + '/original.png'; - var resized = dir + '/resize'; + const original = path.join(dir, 'original.png'); + const resized = path.join(dir, 'resize'); var widths = [300, 700, 400, 800, 200], i, cb; var resizeExact = function (width, index) { var name = resized + index + '.png'; diff --git a/test/roll.js b/test/roll.js index 2c246339..1554841a 100644 --- a/test/roll.js +++ b/test/roll.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -14,8 +14,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/roll.png', function roll (err) { + const destPath = path.join(dir, 'roll.png'); + m.write(destPath, function roll (err) { finish(err); }); } diff --git a/test/rotate.js b/test/rotate.js index 42747b85..28bd2cb1 100644 --- a/test/rotate.js +++ b/test/rotate.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -16,13 +16,13 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/rotate.png', function rotate (err, _0, _1, cmd) { + const destPath = path.join(dir, 'rotate.png'); + m.write(destPath, function rotate (err, _0, _1, cmd) { assert.ok(/"-rotate" "-40"/.test(cmd)); m .rotate('red', 0) - .write(dir + '/rotate.png', function rotate (err, _0, _1, cmd) { + .write(destPath, function rotate (err, _0, _1, cmd) { assert.ok(!/"-rotate" "-40"/.test(cmd)); assert.ok(/"-rotate" "0"/.test(cmd)); finish(err); diff --git a/test/scale.js b/test/scale.js index 09b542e2..d9f0e298 100644 --- a/test/scale.js +++ b/test/scale.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -36,8 +36,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/scale.png', function scale (err) { + const destPath = path.join(dir, 'scale.png'); + m.write(destPath, function scale (err) { finish(err); }); } diff --git a/test/selectFrame.js b/test/selectFrame.js index 0626bb6d..ce74b186 100644 --- a/test/selectFrame.js +++ b/test/selectFrame.js @@ -1,8 +1,9 @@ -var assert = require('assert'); -var fs = require('fs') +const assert = require('assert'); +const path = require('path'); module.exports = function (_, dir, finish, gm) { - var m = gm(dir + '/original.gif[0]') + const gifPath = path.join(dir, 'original.gif[0]'); + var m = gm(gifPath); if (!gm.integration) return finish(); diff --git a/test/sepia.js b/test/sepia.js index 12188f90..3c527a28 100644 --- a/test/sepia.js +++ b/test/sepia.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -16,8 +16,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/sepia.png', function sepia (err) { + const destPath = path.join(dir, 'sepia.png'); + m.write(destPath, function sepia (err) { finish(err); }); } diff --git a/test/setFormat.js b/test/setFormat.js index 221fa412..bd465ef0 100644 --- a/test/setFormat.js +++ b/test/setFormat.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -11,8 +11,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/setformat', function setformat (err) { + const destPath = path.join(dir, 'setFormat.png'); + m.write(destPath, function setformat (err) { finish(err); }); } diff --git a/test/sharpen.js b/test/sharpen.js index e6e53a70..bedc1436 100644 --- a/test/sharpen.js +++ b/test/sharpen.js @@ -1,5 +1,5 @@ - -var assert =require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -14,8 +14,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/sharpen.png', function sharpen (err) { + const destPath = path.join(dir, 'sharpen.png'); + m.write(destPath, function sharpen (err) { finish(err); }); } diff --git a/test/solarize.js b/test/solarize.js index a52cc814..10fd0422 100644 --- a/test/solarize.js +++ b/test/solarize.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -14,8 +14,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/solarize.png', function solarize (err) { + const destPath = path.join(dir, 'solarize.png'); + m.write(destPath, function solarize (err) { finish(err); }); } diff --git a/test/spread.js b/test/spread.js index 127003f6..e1ca3a1d 100644 --- a/test/spread.js +++ b/test/spread.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -14,8 +14,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/spread.png', function spread (err) { + const destPath = path.join(dir, 'spread.png'); + m.write(destPath, function spread (err) { finish(err); }); } diff --git a/test/streamIn.js b/test/streamIn.js index 7a51f6d3..4caa7895 100644 --- a/test/streamIn.js +++ b/test/streamIn.js @@ -1,11 +1,12 @@ - -var assert = require('assert') -var fs = require('fs'); +const assert = require('assert'); +const path = require('path'); +const fs = require('fs'); module.exports = function (_, dir, finish, gm) { - var stream = fs.createReadStream(dir + '/original.jpg'); - var m = gm(stream, "original.jpg"); + const originalPath = path.join(dir, 'original.jpg'); + const stream = fs.createReadStream(originalPath); + const m = gm(stream, "original.jpg"); assert.equal(stream, m.sourceStream); assert.equal('original.jpg', m.source); @@ -13,8 +14,8 @@ module.exports = function (_, dir, finish, gm) { if (!gm.integration) return finish(); - m - .write(dir + '/streamIn.png', function streamIn (err) { + const destPath = path.join(dir, 'streamIn.png'); + m.write(destPath, function streamIn (err) { finish(err); }); } diff --git a/test/streamInGetter.js b/test/streamInGetter.js index 9fed5f99..554364e4 100644 --- a/test/streamInGetter.js +++ b/test/streamInGetter.js @@ -1,14 +1,15 @@ - -var assert = require('assert') -var fs = require('fs'); +const path = require('path'); +const fs = require('fs'); module.exports = function (_, dir, finish, gm) { if (!gm.integration) return finish(); - gm(fs.createReadStream(dir + '/original.jpg')) + const originalPath = path.join(dir, 'original.jpg'); + gm(fs.createReadStream(originalPath)) .size({bufferStream: true}, function (err, size) { - this.write(dir + '/streamInGetter.png', function streamInGetter (err){ + const destPath = path.join(dir, 'streamInGetter.png'); + this.write(destPath, function streamInGetter (err){ finish(err); }); }); diff --git a/test/streamInOut.js b/test/streamInOut.js index aea32a2d..fdaafe82 100644 --- a/test/streamInOut.js +++ b/test/streamInOut.js @@ -1,15 +1,17 @@ - -var fs = require('fs'); +const path = require('path'); +const fs = require('fs'); module.exports = function (_, dir, finish, gm) { if (!gm.integration) return finish(); - gm(fs.createReadStream(dir + '/original.jpg'), "original.jpg") + const originalPath = path.join(dir, 'original.jpg'); + gm(fs.createReadStream(originalPath), "original.jpg") .stream(function streamOut (err, stdout, stderr) { if (err) return finish(err); - stdout.pipe(fs.createWriteStream(dir + '/streamInOut.jpg')); + const destPath = path.join(dir, 'streamInOut.jpg'); + stdout.pipe(fs.createWriteStream(destPath)); stdout.on('error', finish); stdout.on('close', finish); }); diff --git a/test/streamOut.js b/test/streamOut.js index 3b070db2..222787cf 100644 --- a/test/streamOut.js +++ b/test/streamOut.js @@ -1,5 +1,5 @@ - -var fs = require('fs'); +const path = require('path'); +const fs = require('fs'); module.exports = function (gm, dir, finish, GM) { @@ -16,7 +16,8 @@ module.exports = function (gm, dir, finish, GM) { gm .stream(function streamOut (err, stdout, stderr) { if (err) return done(err); - stdout.pipe(fs.createWriteStream(dir + '/streamOut.png')); + const destPath = path.join(dir, 'streamOut.png'); + stdout.pipe(fs.createWriteStream(destPath)); stdout.on('error', done); stdout.on('close', done); }); @@ -25,7 +26,8 @@ module.exports = function (gm, dir, finish, GM) { function withoutCallback(done) { var stream = gm.stream() stream.on('error', done) - stream.pipe(fs.createWriteStream(dir + '/streamOut2.png')) + const destPath = path.join(dir, 'streamOut2.png'); + stream.pipe(fs.createWriteStream(destPath)) stream.on('end', done) } } diff --git a/test/streamOutFormat.js b/test/streamOutFormat.js index 4924d265..71a81957 100644 --- a/test/streamOutFormat.js +++ b/test/streamOutFormat.js @@ -1,18 +1,8 @@ - -var assert = require('assert') -var fs = require('fs'); +const assert = require('assert') +const path = require('path'); +const fs = require('fs'); module.exports = function (gm, dir, finish, GM) { - /* - assert.throws(function () { - gm.stream() - }, /expects a callback/); - - assert.throws(function () { - gm.stream('PNG') - }, /expects a callback/); - */ - if (!GM.integration) return finish(); @@ -30,7 +20,8 @@ module.exports = function (gm, dir, finish, GM) { gm .stream('PNG', function streamOut (err, stdout, stderr) { if (err) return done(err); - stdout.pipe(fs.createWriteStream(dir + '/streamOut.png')); + const destPath = path.join(dir, 'streamOutFormat.png'); + stdout.pipe(fs.createWriteStream(destPath)); stdout.on('error', done); stdout.on('close', done); }); @@ -39,7 +30,8 @@ module.exports = function (gm, dir, finish, GM) { function withoutCallback(done) { var stream = gm.stream('PNG') stream.on('error', done) - stream.pipe(fs.createWriteStream(dir + '/streamOut2.png')) + const destPath = path.join(dir, 'streamOutFormat2.png'); + stream.pipe(fs.createWriteStream(destPath)) stream.on('end', done) } diff --git a/test/strip.js b/test/strip.js index d08cfe8b..7f7c0cb7 100644 --- a/test/strip.js +++ b/test/strip.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -15,8 +15,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/edge.png', function edge (err) { + const destPath = path.join(dir, 'strip.png'); + m.write(destPath, function edge (err) { finish(err); }); } diff --git a/test/subclass.js b/test/subclass.js index 08ee5b15..3d251f9b 100644 --- a/test/subclass.js +++ b/test/subclass.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (_, dir, finish, gm) { assert.equal('gm', gm('test').constructor.name); @@ -23,8 +23,10 @@ module.exports = function (_, dir, finish, gm) { if (!gm.integration) return finish(); - gm(dir + '/photo.JPG') - .thumb(50, 80, dir + '/SUBthumb.png', function subthumb (err) { + const sourcePath = path.join(dir, 'photo.JPG'); + const destPath = path.join(dir, 'subclass.png'); + gm(sourcePath) + .thumb(50, 80, destPath, function subthumb (err) { if (err) return finish(err); finish(); }); diff --git a/test/swirl.js b/test/swirl.js index d12d917f..51f1b0c8 100644 --- a/test/swirl.js +++ b/test/swirl.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -14,8 +14,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/swirl.png', function swirl (err) { + const destPath = path.join(dir, 'swirl.png'); + m.write(destPath, function swirl (err) { finish(err); }); } diff --git a/test/text.js b/test/text.js index 8e9314ca..8e680cc6 100644 --- a/test/text.js +++ b/test/text.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -32,8 +32,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/text.png', function text (err) { + const destPath = path.join(dir, 'text.png'); + m.write(destPath, function text (err) { finish(err); }); } diff --git a/test/thumb.js b/test/thumb.js index 071b3217..e180a844 100644 --- a/test/thumb.js +++ b/test/thumb.js @@ -1,13 +1,13 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - gm - .thumb(150, 40, dir + '/thumb.png', function thumb (err) { + const destPath = path.join(dir, 'thumb.png'); + gm.thumb(150, 40, destPath, function thumb (err) { finish(err); }); } diff --git a/test/thumbnail.js b/test/thumbnail.js index cb9da86c..28054054 100644 --- a/test/thumbnail.js +++ b/test/thumbnail.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (gm, dir, finish, GM) { @@ -14,8 +14,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - m - .write(dir + '/thumbnail.png', function thumbnail (err) { + const destPath = path.join(dir, 'thumbnail.png'); + m.write(destPath, function thumbnail (err) { finish(err); }); } diff --git a/test/timeout.js b/test/timeout.js index a7e6e762..ab416d20 100644 --- a/test/timeout.js +++ b/test/timeout.js @@ -1,5 +1,5 @@ - -var assert = require('assert') +const assert = require('assert'); +const path = require('path'); module.exports = function (img, dir, finish, gm) { @@ -16,16 +16,18 @@ module.exports = function (img, dir, finish, gm) { if (!gm.integration) return finish(); - gm(dir + '/photo.JPG').options({ timeout: 1 }) - .thumb(50, 80, dir + '/timeout.png', function subthumb (err) { + const sourcePath = path.join(dir, 'photo.JPG'); + const timeoutPath = path.join(dir, 'timeout.png'); + gm(sourcePath).options({ timeout: 1 }) + .thumb(50, 80, timeoutPath, function subthumb (err) { assert.ok(err, "Expecting a timeout error"); noTimeout(); }); function noTimeout() { - gm(dir + '/photo.JPG').options({ timeout: 0 }) - .thumb(50, 80, dir + '/timeout.png', function subthumb (err) { + gm(sourcePath).options({ timeout: 0 }) + .thumb(50, 80, timeoutPath, function subthumb (err) { finish(err); }); } diff --git a/test/webp.js b/test/webp.js index 65890a1d..5cb7b155 100644 --- a/test/webp.js +++ b/test/webp.js @@ -1,20 +1,21 @@ -var assert = require('assert') -var fs = require('fs') +const assert = require('assert'); +const path = require('path'); +const fs = require('fs') module.exports = function (_, dir, finish, gm, im) { if (!gm.integration) return finish() // Don't know how to install IM with WEBP on ubuntu - if (require('os').platform() === 'linux') return finish() + // if (require('os').platform() === 'linux') return finish() // GraphicsMagick currently does not support webp :( - if (!im) return finish() + // if (!im) return finish() gm = gm.subClass({ imageMagick: true }) - var image = dir + '/original.png' + const imagePath = path.join(dir, 'original.png'); write(function (err) { if (err) return finish(err) @@ -23,11 +24,12 @@ module.exports = function (_, dir, finish, gm, im) { }) function write(done) { - gm(image) - .write(dir + '/original.x.webp', function (err) { + const webpPath = path.join(dir, 'original.x.webp'); + gm(imagePath) + .write(webpPath, function (err) { if (err) return done(err) - gm(dir + '/original.x.webp').identify(function (err, value) { + gm(webpPath).identify(function (err, value) { if (err) return done(err) assert.ok(value) @@ -38,7 +40,7 @@ module.exports = function (_, dir, finish, gm, im) { } function stream(done) { - gm(image) + gm(imagePath) .stream('webp', function (err, stdout) { if (err) return done(err) From 7c5a26093b7a0a46b37ba4884bbba224803104fc Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Tue, 20 Sep 2022 08:12:53 -0700 Subject: [PATCH 60/64] tests; increase output --- test/index.js | 58 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/test/index.js b/test/index.js index 2725c0ec..af1f1135 100644 --- a/test/index.js +++ b/test/index.js @@ -40,10 +40,24 @@ function finish (filename) { console.error('\n\nError occured with file: ' + filename); throw err; } + } +} + +function isGraphicsMagickInstalled() { + try { + cp.execSync('gm -version'); + return true; + } catch (_) { + return false; + } +} - process.stdout.write('\033[2K'); - process.stdout.write('\033[0G'); - process.stdout.write('pending ' + (q.length()+q.running())); +function isConvertInstalled() { + try { + cp.execSync('convert -version'); + return true; + } catch (_) { + return false; } } @@ -56,12 +70,11 @@ function isMagickInstalled() { } } -process.stdout.write('\033[?25l'); - var q = Async.queue(function (task, callback) { var filename = task.filename; var im = task.imagemagick; + console.log(`Testing ${filename} ..`); require(filename)(test(im), dir, function (err) { finish(filename)(err); callback(); @@ -69,29 +82,32 @@ var q = Async.queue(function (task, callback) { }, 1); q.drain = function(){ - process.stdout.write('\033[?25h'); - process.stdout.write('\033[2K'); - process.stdout.write('\033[0G'); - console.error("\n\u001B[32mAll tests passed\u001B[0m"); + console.log("\n\u001B[32mAll tests passed\u001B[0m"); }; files = files.map(function (file) { return path.join(__dirname, file); }); -files.forEach(function (filename) { - q.push({ - imagemagick: false, - filename - }) -}); +if (isGraphicsMagickInstalled()) { + console.log('gm is installed'); + files.forEach(function (filename) { + q.push({ + imagemagick: false, + filename + }) + }); +} -files.forEach(function (filename) { - q.push({ - imagemagick: true, - filename - }) -}); +if (isConvertInstalled()) { + console.log('convert is installed'); + files.forEach(function (filename) { + q.push({ + imagemagick: true, + filename + }) + }); +} if (isMagickInstalled()) { console.log('magick is installed'); From 01e4217aa3db80d1aee57f66d9dfa4545d2cb804 Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Tue, 20 Sep 2022 08:26:31 -0700 Subject: [PATCH 61/64] test; temporarily enable debug logs --- .github/workflows/node.js.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 2bfbe4bf..c3ef35c1 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -13,6 +13,9 @@ jobs: build: runs-on: ${{ matrix.os }} + env: + DEBUG: "gm*" + strategy: matrix: os: [ubuntu-latest, windows-latest] From d282ef7b09d6dae978e84111e2ba3d05d5d9200b Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Tue, 20 Sep 2022 08:26:48 -0700 Subject: [PATCH 62/64] tests; windows support --- .github/workflows/node.js.yml | 2 +- test/109.js | 4 +-- test/118.js | 6 ++--- test/393.js | 7 +++-- test/417.js | 28 +++++++++----------- test/422.js | 17 +++++++----- test/429.js | 9 +++---- test/70.js | 5 ++-- test/alpha.js | 10 +++---- test/append.js | 20 +++++++------- test/autoOrient.js | 17 ++++++++---- test/autoOrientAll.js | 12 +++++---- test/autoOrientAndThumb.js | 13 ++++----- test/autoOrientStream.js | 13 +++++---- test/compare.js | 9 +++---- test/crop.js | 4 +-- test/densityGm.js | 15 ++++++----- test/densityIm.js | 22 ---------------- test/dispose.js | 10 +++---- test/flatten.js | 6 ++--- test/fromBuffer.js | 12 ++++----- test/geometry.js | 8 +++--- test/getterColor.js | 4 +-- test/getterFormatGIF.js | 4 +-- test/getterIdentify.js | 16 +++++------ test/getterIptc.js | 9 +++---- test/getterMultipleIptc.js | 9 +++---- test/getterSize.js | 13 ++++----- test/gifFrame.js | 4 +-- test/gifFrameIdentify.js | 4 +-- test/gifFrameStream.js | 5 ++-- test/index.js | 13 ++++----- test/interlace.js | 4 +-- test/new.js | 3 ++- test/newImage.js | 3 ++- test/options.js | 38 ++++++++++++++++++++------- test/repagePlus.js | 5 +--- test/resize.js | 20 +++++++------- test/resizeAndAutoOrientFromBuffer.js | 25 ++++++++---------- test/resizeBuffer.js | 11 ++++---- test/resizeWrong.js | 5 ++-- test/scale.js | 12 ++++----- test/selectFrame.js | 4 +-- test/streamIn.js | 4 +-- test/streamInGetter.js | 3 ++- test/streamInOut.js | 3 ++- test/streamOutFormat.js | 4 +-- test/strip.js | 2 +- test/subclass.js | 5 ++-- test/timeout.js | 6 ++--- test/webp.js | 4 +-- 51 files changed, 243 insertions(+), 248 deletions(-) delete mode 100644 test/densityIm.js diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index c3ef35c1..81f7b37b 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -18,7 +18,7 @@ jobs: strategy: matrix: - os: [ubuntu-latest, windows-latest] + os: [windows-latest, ubuntu-latest] node-version: [14.x, 16.x, 18.x] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ diff --git a/test/109.js b/test/109.js index 70cb3adc..41332380 100644 --- a/test/109.js +++ b/test/109.js @@ -1,12 +1,12 @@ const fs = require('fs'); const path = require('path'); -module.exports = function (_, dir, finish, gm) { +module.exports = function (_, dir, finish, gm, imageMagick) { if (!gm.integration) return finish(); const original = path.join(dir, 'original.jpg'); const buf = fs.readFileSync(original); - const m = gm(buf, 'original.jpg'); + const m = gm(buf, 'original.jpg').options({ imageMagick }); m.identify(function (err, _) { finish(err); diff --git a/test/118.js b/test/118.js index 8048ec3f..17c98d5f 100644 --- a/test/118.js +++ b/test/118.js @@ -9,14 +9,14 @@ const assert = require('assert') const path = require('path'); -module.exports = function (_, dir, finish, gm) { +module.exports = function (_, dir, finish, gm, imageMagick) { if (!gm.integration) return finish(); var src = path.join(dir, 'originalSideways.jpg'); var dst = path.join(dir, 'originalSideways10x.jpg'); - gm(src).resize(10).write(dst, function(err) { - gm(dst).size(function(err, size) { + gm(src).options({ imageMagick }).resize(10).write(dst, function(err) { + gm(dst).options({ imageMagick }).size(function(err, size) { if (err) return finish(err); assert.equal(10, size.width); finish(); diff --git a/test/393.js b/test/393.js index 790ac043..dc0cdb45 100644 --- a/test/393.js +++ b/test/393.js @@ -2,13 +2,12 @@ const assert = require('assert'); const fs = require('fs'); const path = require('path'); -module.exports = function (_, dir, finish, gm) { +module.exports = function (_, dir, finish, gm, imageMagick) { if (!gm.integration) return finish(); - var imagePath = path.join(__dirname, './fixtures', 'nyancat.gif'); + var imagePath = path.join(__dirname, 'fixtures', 'nyancat.gif'); var inputStream = fs.createReadStream(imagePath); - gm(inputStream) - .identify({ bufferStream: true }, function(err, value) { + gm(inputStream).options({ imageMagick }).identify({ bufferStream: true }, function(err, value) { if (err) return finish(err); var size = value.size; assert.equal(400, size.width); diff --git a/test/417.js b/test/417.js index b179bc17..2e88952c 100644 --- a/test/417.js +++ b/test/417.js @@ -3,31 +3,27 @@ const assert = require('assert') const fs = require('fs'); const path = require('path'); -module.exports = function (_, dir, finish, gm) { +module.exports = function (_, dir, finish, gm, imageMagick) { if (!gm.integration) return finish(); const originalPathName = path.join(dir, 'original.jpg'); const thumbPathName = path.join(dir, 'thumb.png'); - gm(originalPathName) - .thumb(150, 40, thumbPathName, function thumb (err) { - gm(thumbPathName) - .size(function (err, size) { - if (err) return finish(err); + gm(originalPathName).options({ imageMagick }).thumb(150, 40, thumbPathName, function thumb (err) { + gm(thumbPathName).options({ imageMagick }).size(function (err, size) { + if (err) return finish(err); - assert.equal(142, size.width); - assert.equal(40, size.height); + assert.equal(142, size.width); + assert.equal(40, size.height); - gm(originalPathName) - .thumbExact(150, 40, thumbPathName, function thumb (err) { - gm(thumbPathName) - .size(function (err, size) { - assert.equal(150, size.width); - assert.equal(40, size.height); - finish(err); - }); + gm(originalPathName).options({ imageMagick }).thumbExact(150, 40, thumbPathName, function thumb (err) { + gm(thumbPathName).options({ imageMagick }).size(function (err, size) { + assert.equal(150, size.width); + assert.equal(40, size.height); + finish(err); }); }); + }); }); } diff --git a/test/422.js b/test/422.js index dfc15f6b..d980439e 100644 --- a/test/422.js +++ b/test/422.js @@ -1,13 +1,16 @@ const fs = require('fs'); const path = require('path'); -module.exports = function (gm, dir, finish, GM) { +module.exports = function (gm, dir, finish, GM, imageMagick) { // Same image const originalPathName = path.join(dir, 'original.jpg'); - GM.compare(originalPathName, originalPathName, function(err, same) { + gm.compare(originalPathName, originalPathName, function(err, same, diff) { if (err) return finish(err); - if (!same) return finish(new Error('Compare should be the same!')); + if (!same) { + const msg = `Compare should be the same! "${same}" "${diff}"`; + return finish(new Error(msg)); + } // Compare almost similar images for which ImageMagick // returns an exponent-style floating point number @@ -16,7 +19,10 @@ module.exports = function (gm, dir, finish, GM) { gm.compare(compare1PathName, compare2PathName, function(err, same, diff) { if (err) return finish(err); - if (!same) return finish(new Error('Compare should be the same!')); + if (!same) { + const msg = `Compare should be the same! "${same}" "${diff}"`; + return finish(new Error(msg)); + } const noisePathName = path.join(dir, 'noise3.png'); @@ -26,7 +32,6 @@ module.exports = function (gm, dir, finish, GM) { var options = { highlightColor: '#fff', - highlightStyle: 'XOR', file: path.join(dir, 'diff.png'), tolerance: 0.001 }; @@ -34,7 +39,7 @@ module.exports = function (gm, dir, finish, GM) { const originalPathName = path.join(dir, 'original.jpg'); // Compare these images and write to a file. - GM.compare(originalPathName, noisePathName, options, function(err) { + gm.compare(originalPathName, noisePathName, options, function(err) { if (err) return finish(err); fs.access(options.file, fs.constants.F_OK, function(err) { diff --git a/test/429.js b/test/429.js index dd8a7ed5..115884ba 100644 --- a/test/429.js +++ b/test/429.js @@ -1,27 +1,26 @@ -const assert = require('assert'); const fs = require('fs'); const path = require('path'); -module.exports = function (gm, dir, finish, GM) { +module.exports = function (gm, dir, finish, GM, imageMagick) { if (!GM.integration) return finish(); const ico = path.join(__dirname, 'fixtures', 'test.ico'); const buffer = fs.readFileSync(ico); const stream = fs.createReadStream(ico); - GM(ico).size(function (err, size) { + GM(ico).options({ imageMagick }).size(function (err) { if (err) { err.message = 'Failed using ico filename. ' + err.message; return finish(err); } - GM(buffer, 'img.ico').size(function (err, size) { + GM(buffer, 'img.ico').options({ imageMagick }).size(function (err) { if (err) { err.message = 'Failed using ico buffer. ' + err.message; return finish(err); } - GM(stream, 'img.ico').size({bufferStream: true}, function (err, size) { + GM(stream, 'img.ico').options({ imageMagick }).size({bufferStream: true}, function (err) { if (err) { err.message = 'Failed using ico stream. ' + err.message; return finish(err); diff --git a/test/70.js b/test/70.js index 32dfc14a..5e34bdab 100644 --- a/test/70.js +++ b/test/70.js @@ -6,7 +6,7 @@ var times = 16; var loading = path.join(__dirname, 'fixtures', 'loading.gif'); var favicon = path.join(__dirname, 'fixtures', 'favicon.png'); -module.exports = function (_, dir, finish, gm) { +module.exports = function (_, dir, finish, gm, imageMagick) { if (!gm.integration) return finish(); var pending = times/2; @@ -24,8 +24,7 @@ module.exports = function (_, dir, finish, gm) { new Array(times).join('x').split('x').forEach(function (_, i) { ;[loading, favicon].forEach(function (img) { - gm(img) - .size(function edge (err, size) { + gm(img).options({imageMagick}).size(function (err, size) { if (err) return done(err); 'width height'.split(' ').forEach(function (prop) { diff --git a/test/alpha.js b/test/alpha.js index 161076c3..67051cf9 100644 --- a/test/alpha.js +++ b/test/alpha.js @@ -2,7 +2,7 @@ const assert = require('assert'); const Async = require('async'); const path = require('path'); -module.exports = function (_, dir, finish, gm, im) { +module.exports = function (_, dir, finish, gm, imageMagick) { if (!gm.integration) return finish(); var alphaTypes = [ @@ -19,11 +19,11 @@ module.exports = function (_, dir, finish, gm, im) { "Background" ]; - const edgePath = path.join(dir, 'edge.png'); + const edgePath = path.join(dir, 'original.png'); const failPath = path.join(dir, 'alpha_fail.png'); // alpha not supported by GM so only test IM - if (!im) { + if (!imageMagick) { assert.throws(function() { gm(edgePath) .alpha(alphaTypes.pop()) @@ -32,8 +32,8 @@ module.exports = function (_, dir, finish, gm, im) { finish(); } else { - Async.eachSeries(alphaTypes, function(alphaType,cb) { - var m = gm(edgePath).options({imageMagick: im}).alpha( alphaType ); + Async.eachSeries(alphaTypes, function(alphaType, cb) { + var m = gm(edgePath).options({imageMagick}).alpha( alphaType ); var args = m.args(); assert.equal('convert', args[0]); assert.equal('-alpha', args[2]); diff --git a/test/append.js b/test/append.js index 1976b202..b5603f6d 100644 --- a/test/append.js +++ b/test/append.js @@ -1,7 +1,7 @@ const assert = require('assert') const path = require('path'); -module.exports = function (_, dir, finish, gm) { +module.exports = function (_, dir, finish, gm, imageMagick) { const out = path.resolve(dir, 'append.jpg'); const lostPath = path.join(dir, 'lost.png'); const originalPath = path.join(dir, 'original.jpg'); @@ -11,6 +11,7 @@ module.exports = function (_, dir, finish, gm) { } catch (_) {} var m = gm(lostPath) + .options({imageMagick}) .append(originalPath, originalPath) .append() .background('#222') @@ -26,25 +27,27 @@ module.exports = function (_, dir, finish, gm) { assert.equal('-',args[7]); if (!gm.integration) { - return horizontal({ dir, finish, gm, originalPath, lostPath }); + return horizontal({ dir, finish, gm, originalPath, lostPath, imageMagick }); } m.write(out, function (err) { if (err) return finish(err); - gm(out).size(function (err, size) { + gm(out) + .options({imageMagick}) + .size(function (err, size) { if (err) return finish(err); assert.equal(460, size.width); assert.equal(435, size.height); - horizontal({ dir, finish, gm, originalPath, lostPath }); + horizontal({ dir, finish, gm, originalPath, lostPath, imageMagick }); }) }); } -function horizontal ({ dir, finish, gm, originalPath, lostPath }) { +function horizontal ({ dir, finish, gm, originalPath, lostPath, imageMagick }) { var out = path.resolve(dir, 'appendHorizontal.jpg'); - var m = gm(originalPath).append(lostPath, true); + var m = gm(originalPath).append(lostPath, true).options({imageMagick}); var args = m.args(); assert.equal('convert', args[0]); @@ -57,10 +60,9 @@ function horizontal ({ dir, finish, gm, originalPath, lostPath }) { return finish(); } - m - .write(out, function (err) { + m.write(out, function (err) { if (err) return finish(err); - gm(out).size(function (err, size) { + gm(out).options({imageMagick}).size(function (err, size) { if (err) return finish(err); assert.equal(697, size.width); assert.equal(155, size.height); diff --git a/test/autoOrient.js b/test/autoOrient.js index c78bb405..cbeb07ec 100644 --- a/test/autoOrient.js +++ b/test/autoOrient.js @@ -1,28 +1,35 @@ const assert = require('assert'); const path = require('path'); -module.exports = function (_, dir, finish, gm) { +module.exports = function (_, dir, finish, gm, imageMagick) { if (!gm.integration) return finish(); const sidewaysPath = path.join(dir, 'originalSideways.jpg'); - gm(sidewaysPath).identify(function (err, o) { + gm(sidewaysPath) + .options({imageMagick}) + .identify(function (err, o) { if (err) return finish(err); - assert.equal('155x460', o.Geometry); + const geo = imageMagick ? '155x460+0+0' : '155x460'; + assert.equal(geo, o.Geometry); // this image is sideways, but may be auto-oriented by modern OS's // try opening it in a browser to see its true orientation gm(sidewaysPath) + .options({imageMagick}) .autoOrient() .stream(function (err, stream) { if (err) return finish(err); - gm(stream).identify(function (err, data) { + gm(stream) + .options({imageMagick}) + .identify(function (err, data) { if (err) return finish(err); - assert.equal('460x155', data.Geometry); + const geo2 = imageMagick ? '460x155+0+0' : '460x155'; + assert.equal(geo2, data.Geometry); finish(err); }) }) diff --git a/test/autoOrientAll.js b/test/autoOrientAll.js index aebb24a8..82550872 100644 --- a/test/autoOrientAll.js +++ b/test/autoOrientAll.js @@ -2,7 +2,7 @@ const assert = require('assert'); const fs = require('fs'); const path = require('path'); -module.exports = function (_, dir, finish, gm) { +module.exports = function (_, dir, finish, gm, imageMagick) { if (!gm.integration) return finish(); var beforeValues = { @@ -65,7 +65,7 @@ module.exports = function (_, dir, finish, gm) { const newFilename = fileToAutoOrient + '.oriented.jpg'; const constant = fileToAutoOrient + '.correct.jpg'; - gm(fileToAutoOrient).orientation(function (err, o) { + gm(fileToAutoOrient).options({imageMagick}).orientation(function (err, o) { if (err) return finish(err); assert.equal(beforeValues[filename][0], o); @@ -74,18 +74,20 @@ module.exports = function (_, dir, finish, gm) { // this image is sideways, but may be auto-oriented by modern OS's // try opening it in a browser to see its true orientation gm(fileToAutoOrient) + .options({ imageMagick }) .autoOrient() .write(newFilename, function autoOrient (err) { if (err) return finish(err); // fs race condition setTimeout(function () { - gm(newFilename).identify(function (err) { + gm(newFilename).options({ imageMagick }).identify(function (err) { if (err) return finish(err); - assert.equal(afterValues[filename], this.data.Geometry, 'Bad-Geometry for ' + filename); + const afterValue = imageMagick ? `${afterValues[filename]}+0+0` : afterValues[filename]; + assert.equal(afterValue, this.data.Geometry, `Bad-Geometry for ${filename}. Got "${this.data.Geometry}"`); - gm.compare(newFilename, constant, 0.1, function (err, equal) { + gm().options({imageMagick}).compare(newFilename, constant, 0.1, function (err, equal) { if (err) return finish(err); assert.ok(equal); next(); diff --git a/test/autoOrientAndThumb.js b/test/autoOrientAndThumb.js index 618b89b1..5bc004cf 100755 --- a/test/autoOrientAndThumb.js +++ b/test/autoOrientAndThumb.js @@ -1,25 +1,26 @@ const assert = require('assert') const path = require('path'); -module.exports = function (_, dir, finish, gm) { +module.exports = function (_, dir, finish, gm, imageMagick) { if (!gm.integration) return finish(); var original = path.join(dir, 'orientation', 'Portrait_7.jpg'); var result = path.join(dir, 'autoOrientAndThumb.png'); - size(original, function (err, origSize) { + size(original, imageMagick, function (err, origSize) { if (err) return finish(err); assert.ok(origSize.width < 610); assert.ok(origSize.height < 460); - var m = gm(original) + gm(original) + .options({imageMagick}) .autoOrient() .thumb(100, 100, result, function (err) { if (err) return finish(err); - size(result, function (err, newSize) { + size(result, imageMagick, function (err, newSize) { if (err) return finish(err); assert.ok(newSize.width < 80); assert.ok(newSize.height < 110); @@ -29,8 +30,8 @@ module.exports = function (_, dir, finish, gm) { }); }); - function size (file, cb) { - gm(file).identify(function (err, data) { + function size (file, imageMagick, cb) { + gm(file).options({imageMagick}).identify(function (err, data) { if (err) return cb(err); cb(err, data.size); }); diff --git a/test/autoOrientStream.js b/test/autoOrientStream.js index 1502cc7a..4a49ba71 100644 --- a/test/autoOrientStream.js +++ b/test/autoOrientStream.js @@ -6,31 +6,34 @@ const assert = require('assert') const fs = require('fs') const path = require('path'); -module.exports = function (_, dir, finish, gm) { +module.exports = function (_, dir, finish, gm, imageMagick) { if (!gm.integration) return finish(); const filename = path.join(dir, 'autoOrientStream.jpg'); const sidewaysPathName = path.join(dir, 'originalSideways.jpg'); - gm(fs.createReadStream(sidewaysPathName)).identify(function (err) { + gm(fs.createReadStream(sidewaysPathName)).options({imageMagick}).identify(function (err) { if (err) return finish(err); - assert.equal('155x460', this.data.Geometry); + const geo = imageMagick ? '155x460+0+0' : '155x460'; + assert.equal(geo, this.data.Geometry); // this image is sideways, but may be auto-oriented by modern OS's // try opening it in a browser to see its true orientation gm(fs.createReadStream(sidewaysPathName)) + .options({imageMagick}) .autoOrient() .write(filename, function autoOrient (err) { if (err) return finish(err); // fs race condition setTimeout(function () { - gm(filename).identify(function (err) { + gm(filename).options({imageMagick}).identify(function (err) { if (err) return finish(err); - assert.equal('460x155', this.data.Geometry); + const geo2 = imageMagick ? '460x155+0+0' : '460x155'; + assert.equal(geo2, this.data.Geometry); finish(err); }); diff --git a/test/compare.js b/test/compare.js index 13a868e5..8d97469b 100644 --- a/test/compare.js +++ b/test/compare.js @@ -1,12 +1,12 @@ const path = require('path'); const fs = require('fs'); -module.exports = function (gm, dir, finish, GM) { +module.exports = function (gm, dir, finish) { // Same image const originalJPGFilePath = path.join(dir, 'original.jpg'); const originalPNGFilePath = path.join(dir, 'original.png'); - GM.compare(originalJPGFilePath, originalPNGFilePath, function(err, same) { + gm.compare(originalJPGFilePath, originalPNGFilePath, function(err, same) { if (err) return finish(err); if (!same) return finish(new Error('Compare should be the same!')); @@ -24,15 +24,14 @@ module.exports = function (gm, dir, finish, GM) { gm.noise(0.3).write(noisePath, function (err) { if (err) return finish(err); - var options = { + const options = { highlightColor: 'yellow', - highlightStyle: 'XOR', file: path.join(dir, `compare-test-${Date.now()}.png`), tolerance: 0.001 }; // Compare these images and write to a file. - GM.compare(originalJPGFilePath, noisePath, options, function(err) { + gm.compare(originalJPGFilePath, noisePath, options, function(err) { if (err) return finish(err); fs.access(options.file, fs.constants.F_OK, function(err) { diff --git a/test/crop.js b/test/crop.js index ac11e455..07195eb5 100644 --- a/test/crop.js +++ b/test/crop.js @@ -1,7 +1,7 @@ const assert = require('assert') const path = require('path'); -module.exports = function (gm, dir, finish, GM) { +module.exports = function (gm, dir, finish, GM, imageMagick) { const m = gm.crop(200, 155, 300, 0); const args = m.args(); @@ -10,7 +10,7 @@ module.exports = function (gm, dir, finish, GM) { assert.equal('200x155+300+0', args[3]); const imagePath = path.join(dir, 'image.png'); - const m2 = GM(imagePath).crop(200, 155, 300, 0, true); + const m2 = GM(imagePath).options({ imageMagick }).crop(200, 155, 300, 0, true); const args2 = m2.args(); assert.equal('200x155+300+0%', args2[3]); diff --git a/test/densityGm.js b/test/densityGm.js index 89c651bb..ceab256b 100644 --- a/test/densityGm.js +++ b/test/densityGm.js @@ -1,20 +1,23 @@ const assert = require('assert') const path = require('path'); -module.exports = function (gm, dir, finish, GM) { - const isImageMagickTest = !!gm._options.imageMagick; - +module.exports = function (gm, dir, finish, GM, imageMagick) { var NUMBER = 100; var NUMBER2 = 200; - var g = gm.density(NUMBER, NUMBER2); - var gArgs = g.args(); assert.equal('convert', gArgs[0]); assert.equal('-density', gArgs[1]); assert.equal(NUMBER + 'x' + NUMBER2, gArgs[2]); - if (isImageMagickTest) return finish(); + if (imageMagick) { + // graphicsmagick does not support density with two arguments + var imArgs = GM().options({imageMagick}).density(NUMBER).args(); + assert.equal('convert', imArgs[0]); + assert.equal('-density', imArgs[1]); + assert.equal(NUMBER, imArgs[2]); + } + if (!GM.integration) return finish(); const destPath = path.join(dir, 'density.png'); diff --git a/test/densityIm.js b/test/densityIm.js deleted file mode 100644 index 27e58a6b..00000000 --- a/test/densityIm.js +++ /dev/null @@ -1,22 +0,0 @@ -const assert = require('assert') -const path = require('path'); - -module.exports = function (gm, dir, finish, GM) { - const isImageMagickTest = !!gm._options.imageMagick; - - var NUMBER = 100; - var im = gm.options({imageMagick: true}).density(NUMBER); - - var imArgs = im.args(); - assert.equal('convert', imArgs[0]); - assert.equal('-density', imArgs[1]); - assert.equal(NUMBER, imArgs[2]); - - if (isImageMagickTest) return finish(); - if (!GM.integration) return finish(); - - const destPath = path.join(dir, 'density.png'); - im.write(destPath, function density (err) { - finish(err); - }); -}; diff --git a/test/dispose.js b/test/dispose.js index ec7cc726..67b9598b 100644 --- a/test/dispose.js +++ b/test/dispose.js @@ -1,7 +1,7 @@ const assert = require('assert') const path = require('path'); -module.exports = function (img, dir, finish, gm) { +module.exports = function (img, dir, finish, gm, imageMagick) { var EventEmitter = require('events').EventEmitter; EventEmitter.prototype._maxListeners = 100; @@ -15,10 +15,10 @@ module.exports = function (img, dir, finish, gm) { events: ['pleaseDispose', 'readyToDispose'] }; - var g = gm('test').options({ disposers: [ disposer ] }); + var g = gm('test').options({ disposers: [ disposer ], imageMagick }); assert.deepEqual([disposer], g._options.disposers); - var sub = gm.subClass({ disposers: [ disposer ]}); + var sub = gm.subClass({ disposers: [ disposer ], imageMagick }); assert.deepEqual([disposer], sub.prototype._options.disposers); if (!gm.integration) { @@ -28,7 +28,7 @@ module.exports = function (img, dir, finish, gm) { const photoPath = path.join(dir, 'photo.JPG'); const disposePath = path.join(dir, 'dispose.png'); - gm(photoPath).options({ disposers: [ disposer ]}) + gm(photoPath).options({ disposers: [ disposer ], imageMagick }) .thumb(1000, 1000, disposePath, function (err) { assert.ok(err, "Expecting a disposed error"); }); @@ -38,7 +38,7 @@ module.exports = function (img, dir, finish, gm) { noDispose(); function noDispose() { - gm(photoPath).options({ disposers: [ disposer ]}) + gm(photoPath).options({ disposers: [ disposer ], imageMagick }) .thumb(1000, 1000, disposePath, function (err) { finish(err); }); diff --git a/test/flatten.js b/test/flatten.js index d093bd19..46e04c73 100644 --- a/test/flatten.js +++ b/test/flatten.js @@ -1,16 +1,16 @@ const assert = require('assert'); const path = require('path'); -module.exports = function (img, dir, finish, gm) { +module.exports = function (_, dir, finish, gm, imageMagick) { // graphicsmagick considers PSD broken // http://www.graphicsmagick.org/NEWS.html#may-30-2016 - if (!img._options.imageMagick) { + if (!imageMagick) { return finish(); } const layersPath = path.join(dir, 'layers.psd'); var m = gm(layersPath) - .options({ imageMagick: true }) + .options({ imageMagick }) .flatten(); var args = m.args(); diff --git a/test/fromBuffer.js b/test/fromBuffer.js index 1bb5d6db..c5ab2dc5 100644 --- a/test/fromBuffer.js +++ b/test/fromBuffer.js @@ -2,15 +2,14 @@ const assert = require('assert'); const path = require('path'); const fs = require('fs') -module.exports = function (_, dir, finish, gm) { +module.exports = function (_, dir, finish, gm, imageMagick) { const original = path.join(dir, 'original.jpg'); const result = path.join(dir, 'fromBuffer.png'); var buf = fs.readFileSync(original); - var m = gm(buf) - .rotate('red', 30); + var m = gm(buf).options({imageMagick}).rotate('red', 30); var args = m.args(); assert.equal('convert', args[0]); @@ -23,17 +22,16 @@ module.exports = function (_, dir, finish, gm) { if (!gm.integration) return finish(); - m - .write(result, function crop (err) { + m.write(result, function crop (err) { if (err) return finish(err); // tolerance defaults to 0.4 - gm.compare(original, result, function (err, equal) { + m.compare(original, result, function (err, equal) { if (err) return finish(err); assert.ok(equal); // accepts tolerance argument - gm.compare(original, result, 0.1, function (err, equal, equality, raw) { + m.compare(original, result, 0.1, function (err, equal, equality, raw) { if (err) return finish(err); assert.ok(!equal); assert.ok(equality > 0.1); diff --git a/test/geometry.js b/test/geometry.js index 4dbbbcdd..3df00f39 100644 --- a/test/geometry.js +++ b/test/geometry.js @@ -1,16 +1,16 @@ var assert = require('assert') -module.exports = function (gm, dir, finish, GM) { - var a = GM("dummy").geometry("asdf"); // Custom geometry command +module.exports = function (_, __, finish, GM, imageMagick) { + var a = GM("dummy").options({imageMagick}).geometry("asdf"); // Custom geometry command var args = a.args(); assert.equal('-geometry', args[2]); assert.equal('asdf', args[3]); - var b = GM("dummy").geometry("", 100) + var b = GM("dummy").options({imageMagick}).geometry("", 100); var args = b.args(); assert.equal('-geometry', args[2]); assert.equal('x100', args[3]); // Keep-aspect-ratio command - return finish(); + return finish(); } diff --git a/test/getterColor.js b/test/getterColor.js index 9f95a5a6..793f43fe 100644 --- a/test/getterColor.js +++ b/test/getterColor.js @@ -1,12 +1,12 @@ const assert = require('assert'); const path = require('path'); -module.exports = function (_, dir, finish, gm) { +module.exports = function (_, dir, finish, gm, imageMagick) { if (!gm.integration) return finish(); const destPath = path.join(dir, 'blue.gif'); - gm(destPath).color(function (err, color) { + gm(destPath).options({imageMagick}).color(function (err, color) { if (err) return finish(err); assert.equal(1, color) diff --git a/test/getterFormatGIF.js b/test/getterFormatGIF.js index 0fd6dafd..6a3fcb6f 100644 --- a/test/getterFormatGIF.js +++ b/test/getterFormatGIF.js @@ -1,12 +1,12 @@ const assert = require('assert'); const path = require('path'); -module.exports = function (_, dir, finish, gm) { +module.exports = function (_, dir, finish, gm, imageMagick) { if (!gm.integration) return finish(); const destPath = path.join(dir, 'original.gif'); - gm(destPath) + gm(destPath).options({imageMagick}) .format(function (err, type) { if (err) return finish(err); diff --git a/test/getterIdentify.js b/test/getterIdentify.js index 23d9dfbc..30f5e54f 100755 --- a/test/getterIdentify.js +++ b/test/getterIdentify.js @@ -6,22 +6,19 @@ var isLinux = os.platform() === 'linux' // Be more lax with the errors if we're on linux var errorFactor = isLinux ? 10 : 1.1 -module.exports = function (_, dir, finish, gm) { +module.exports = function (_, dir, finish, gm, imageMagick) { if (!gm.integration) return finish(); - var im = _._options.imageMagick; - const photoPath = path.join(dir, 'photo.JPG'); - var test = gm(photoPath); - if (im) test.options({ imageMagick: true }); + var test = gm(photoPath).options({ imageMagick }); test.identify(function (err) { if (err) return finish(err); var d = this.data; - if (im) { + if (imageMagick) { assert.equal(d.Orientation, 'TopLeft'); assert.equal(d['Geometry'], '430x488+0+0'); assert.equal(d['Print size'], '5.97222x6.77778'); @@ -67,13 +64,12 @@ module.exports = function (_, dir, finish, gm) { function gif (callback) { const bluePath = path.join(dir, 'blue.gif'); - var test = gm(bluePath); - if (im) test.options({ imageMagick: true }); + var test = gm(bluePath).options({ imageMagick }); test.identify(function (err) { if (err) return finish(err); - if (im) { + if (imageMagick) { if (!isLinux) { assert.equal(1, this.data.color); } @@ -108,7 +104,7 @@ module.exports = function (_, dir, finish, gm) { var format = '%f: %m, %wx%h'; var value = 'blue.gif: GIF, 100x200'; - if (im) test.options({ imageMagick: true }); + test.options({ imageMagick }); test.identify(format, function (err, result) { if (err) return finish(err); diff --git a/test/getterIptc.js b/test/getterIptc.js index 73cc6193..89fecf87 100644 --- a/test/getterIptc.js +++ b/test/getterIptc.js @@ -1,22 +1,19 @@ const assert = require('assert'); const path = require('path'); -module.exports = function (_, dir, finish, gm) { +module.exports = function (_, dir, finish, gm, imageMagick) { if (!gm.integration) return finish(); - var im = _._options.imageMagick; - const iptcPath = path.join(__dirname, 'fixtures', 'iptc.jpg'); - var test = gm(iptcPath); - if (im) test.options({ imageMagick: true }); + var test = gm(iptcPath).options({imageMagick}) test.identify(function (err) { if (err) return finish(err); var d = this.data; - if (im) { + if (imageMagick) { var iptc = d['Profiles'] && d['Profiles']['Profile-iptc']; assert.equal(iptc['Caption[2,120]'], 'Some caption with colon space: for example'); } diff --git a/test/getterMultipleIptc.js b/test/getterMultipleIptc.js index f197b17b..4b558b2d 100644 --- a/test/getterMultipleIptc.js +++ b/test/getterMultipleIptc.js @@ -1,22 +1,19 @@ const assert = require('assert'); const path = require('path'); -module.exports = function (_, dir, finish, gm) { +module.exports = function (_, dir, finish, gm, imageMagick) { if (!gm.integration) return finish(); - var im = _._options.imageMagick; - const iptcPath = path.join(__dirname, 'fixtures', 'iptc-multiple.jpg'); - var test = gm(iptcPath); - if (im) test.options({ imageMagick: true }); + var test = gm(iptcPath).options({imageMagick}) test.identify(function (err) { if (err) return finish(err); var d = this.data; - if (im) { + if (imageMagick) { var iptc = d['Profiles'] && d['Profiles']['Profile-iptc']; var keywords = iptc['Keyword[2,25]']; assert(Array.isArray(keywords)); diff --git a/test/getterSize.js b/test/getterSize.js index 422d6ebd..2a480320 100644 --- a/test/getterSize.js +++ b/test/getterSize.js @@ -1,7 +1,7 @@ const assert = require('assert'); const path = require('path'); -module.exports = function (_, dir, finish, gm) { +module.exports = function (_, dir, finish, gm, imageMagick) { if (!gm.integration) return finish(); @@ -17,22 +17,20 @@ module.exports = function (_, dir, finish, gm) { function sizeJPEG(done) { const originalPath = path.join(dir, 'original.jpg'); - gm(originalPath) - .size(function gettersize (err, size) { + gm(originalPath).options({imageMagick}).size(function gettersize (err, size) { if (err) return done(err); assert.equal(size.width, 460); assert.equal(size.height, 155); const identifyParseErrPath = path.join(dir, 'identifyParseErr.jpg'); - gm(identifyParseErrPath).size(done); + gm(identifyParseErrPath).options({imageMagick}).size(done); }); } function sizeGIF(done) { const originalGifPath = path.join(dir, 'original.gif'); - gm(originalGifPath) - .size(function (err, size) { + gm(originalGifPath).options({imageMagick}).size(function (err, size) { if (err) return done(err); assert.equal(size.width, 192) @@ -44,8 +42,7 @@ module.exports = function (_, dir, finish, gm) { function sizePNG(done) { const originalPngPath = path.join(dir, 'original.png'); - gm(originalPngPath) - .size(function (err, size) { + gm(originalPngPath).options({imageMagick}).size(function (err, size) { if (err) return done(err); assert.equal(size.width, 460) diff --git a/test/gifFrame.js b/test/gifFrame.js index d67d3b38..89ee1b0e 100644 --- a/test/gifFrame.js +++ b/test/gifFrame.js @@ -1,12 +1,12 @@ const path = require('path'); -module.exports = function (_, dir, finish, gm) { +module.exports = function (_, dir, finish, gm, imageMagick) { if (!gm.integration) return finish(); const originalGifPath = path.join(dir, 'original.gif[0]'); const gifFramePath = path.join(dir, 'gifFrame.jpg'); - gm(originalGifPath) + gm(originalGifPath).options({imageMagick}) .write(gifFramePath, function gifFrame (err){ finish(err); }); diff --git a/test/gifFrameIdentify.js b/test/gifFrameIdentify.js index 3e16ed1b..d3c3d7bd 100644 --- a/test/gifFrameIdentify.js +++ b/test/gifFrameIdentify.js @@ -1,9 +1,9 @@ const assert = require('assert') const path = require('path'); -module.exports = function (_, dir, finish, gm) { +module.exports = function (_, dir, finish, gm, imageMagick) { const originalGifPath = path.join(dir, 'original.gif[0]'); - var m = gm(originalGifPath); + var m = gm(originalGifPath).options({imageMagick}); if (!gm.integration) return finish(); diff --git a/test/gifFrameStream.js b/test/gifFrameStream.js index 90f773a9..6d79c1e9 100644 --- a/test/gifFrameStream.js +++ b/test/gifFrameStream.js @@ -2,9 +2,10 @@ const assert = require('assert') const path = require('path'); const fs = require('fs'); -module.exports = function (_, dir, finish, gm) { +module.exports = function (_, dir, finish, gm, imageMagick) { const originalGifPath = path.join(dir, 'original.gif'); - var m = gm(fs.createReadStream(originalGifPath), "original.gif[0]") + const readStream = fs.createReadStream(originalGifPath); + const m = gm(readStream, "original.gif[0]").options({imageMagick}); var args = m.args(); assert.equal('convert', args[0]); diff --git a/test/index.js b/test/index.js index af1f1135..39f05082 100644 --- a/test/index.js +++ b/test/index.js @@ -4,6 +4,7 @@ const Async = require('async'); const dir = path.join(__dirname, '..', 'examples', 'imgs'); const gm = require('..'); const fs = require('fs'); +const os = require('os'); const only = process.argv.slice(2); gm.integration = !! ~process.argv.indexOf('--integration'); @@ -27,11 +28,7 @@ function filter (file) { const originalPathName = path.join(dir, 'original.jpg'); function test (imageMagick) { - if (imageMagick) { - return gm(originalPathName).options({ imageMagick }); - } - - return gm(originalPathName); + return gm(originalPathName).options({ imageMagick }); } function finish (filename) { @@ -70,6 +67,8 @@ function isMagickInstalled() { } } +const isWindows = () => os.platform() === 'win32'; + var q = Async.queue(function (task, callback) { var filename = task.filename; var im = task.imagemagick; @@ -99,7 +98,9 @@ if (isGraphicsMagickInstalled()) { }); } -if (isConvertInstalled()) { +if (!isWindows() && isConvertInstalled()) { + // windows has a different convert binary + console.log('convert is installed'); files.forEach(function (filename) { q.push({ diff --git a/test/interlace.js b/test/interlace.js index cbbc4296..20b17cb1 100644 --- a/test/interlace.js +++ b/test/interlace.js @@ -13,8 +13,8 @@ module.exports = function (gm, dir, finish, GM) { if (!GM.integration) return finish(); - const destPath = path.join(dir, 'edge.png'); - m.write(destPath, function edge (err) { + const destPath = path.join(dir, 'interlace.png'); + m.write(destPath, function interlace (err) { finish(err); }); } diff --git a/test/new.js b/test/new.js index b73ffd20..1f4dd1e1 100644 --- a/test/new.js +++ b/test/new.js @@ -1,9 +1,10 @@ const assert = require('assert'); const path = require('path'); -module.exports = function (_, dir, finish, gm) { +module.exports = function (_, dir, finish, gm, imageMagick) { var m = gm(525, 110, "#00ff55aa") + .options({imageMagick}) .fontSize(68) .stroke("#efe", 2) .fill("#555") diff --git a/test/newImage.js b/test/newImage.js index f09e3cb7..89e26a71 100644 --- a/test/newImage.js +++ b/test/newImage.js @@ -3,7 +3,7 @@ const path = require('path'); const fs = require('fs') -module.exports = function (_, dir, finish, gm) { +module.exports = function (_, dir, finish, gm, imageMagick) { if (!gm.integration) return finish(); @@ -24,6 +24,7 @@ module.exports = function (_, dir, finish, gm) { function createImage() { return gm(70, 30, '#000') + .options({imageMagick}) .font("arial", 20) .stroke("#fff", 2) .fill("#888") diff --git a/test/options.js b/test/options.js index aa31cb21..21bec8a1 100644 --- a/test/options.js +++ b/test/options.js @@ -2,7 +2,21 @@ const assert = require('assert'); const path = require('path'); const fs = require('fs'); -module.exports = function (_, dir, finish, gm) { +const checkCmd = (cmd, imageMagick) => { + switch (imageMagick) { + case true: + assert.ok(/^convert /.test(cmd)); + break; + case '7+': + assert.ok(/^magick "convert" /.test(cmd)); + break; + default: + assert.ok(/^gm "convert" /.test(cmd)); + break; + } +} + +module.exports = function (_, dir, finish, gm, imageMagick) { var sub = gm.subClass({ subclassed: true }); var s = sub('test').options({ setWithMethod: 2 }); @@ -20,22 +34,26 @@ module.exports = function (_, dir, finish, gm) { assert.equal(true, s2._options.subclassed); assert.equal(undefined, s2._options.setWithMethod); - const writeFile = path.join(dir, `IM-negative${Math.random()}.png`); - const imageMagick = gm.subClass({ imageMagick: true }); - if (!gm.integration) return finish(); + // test commands + // test with subclass + const photoPath = path.join(dir, 'photo.JPG'); - imageMagick(photoPath) + const writeFile = path.join(dir, `options${Math.random()}.png`); + const instance = gm.subClass({ imageMagick }); + + instance(photoPath) .negative() .write(writeFile, function (err, _1, _2, cmd) { if (err) return finish(err); - assert.ok(/^convert /.test(cmd)); + checkCmd(cmd, imageMagick); fs.stat(writeFile, function (err) { - if (err) return finish(new Error('imagemagick did not write file')); + if (err) return finish(new Error('did not write file')); + try { fs.unlinkSync(writeFile); } catch (e) {} @@ -43,14 +61,14 @@ module.exports = function (_, dir, finish, gm) { /// inline options gm(photoPath) .negative() - .options({ imageMagick: true }) + .options({ imageMagick }) .write(writeFile, function (err, _1, _2, cmd) { if (err) return finish(err); - assert.ok(/^convert /.test(cmd)); + checkCmd(cmd, imageMagick); fs.stat(writeFile, function (err) { - if (err) return finish(new Error('imagemagick did not write file')); + if (err) return finish(new Error('did not write 2nd file')); try { fs.unlinkSync(writeFile); } catch (e) {} diff --git a/test/repagePlus.js b/test/repagePlus.js index 72c587b6..14c63010 100644 --- a/test/repagePlus.js +++ b/test/repagePlus.js @@ -1,10 +1,7 @@ const assert = require('assert'); const path = require('path'); -module.exports = function (gm, dir, finish, GM, im) { - - // GraphicsMagick 1.3.12 using on Travis server does not support "repage+" (>=1.3.16 is needed) - if (require('os').platform() === 'linux' && !im) return finish() +module.exports = function (gm, dir, finish, GM) { var m = gm .repage('+'); diff --git a/test/resize.js b/test/resize.js index fae94c65..af756cc4 100644 --- a/test/resize.js +++ b/test/resize.js @@ -1,47 +1,45 @@ const assert = require('assert'); const path = require('path'); -module.exports = function (gm, dir, finish, GM) { +module.exports = function (gm, dir, finish, GM, imageMagick) { - var a = GM('img.png').resize(10); + var a = GM('img.png').options({imageMagick}).resize(10); var args = a.args(); assert.equal('convert', args[0]); assert.equal('-resize', args[2]); - if (a._options.imageMagick) { + if (imageMagick) { assert.equal('10', args[3]); } else { assert.equal('10x', args[3]); } - var a = GM('img.png').resize(10, 20); + var a = GM('img.png').options({imageMagick}).resize(10, 20); var args = a.args(); assert.equal('convert', args[0]); assert.equal('-resize', args[2]); assert.equal('10x20', args[3]); - var a = GM('img.png').resize(10, false, '%'); + var a = GM('img.png').options({imageMagick}).resize(10, false, '%'); var args = a.args(); assert.equal('convert', args[0]); assert.equal('-resize', args[2]); - if (a._options.imageMagick) { + if (imageMagick) { assert.equal('10%', args[3]); } else { assert.equal('10x%', args[3]); } - var a = GM('img.png').resize('10%'); + var a = GM('img.png').options({imageMagick}).resize('10%'); var args = a.args(); assert.equal('convert', args[0]); assert.equal('-resize', args[2]); - if (a._options.imageMagick) { + if (imageMagick) { assert.equal('10%', args[3]); } else { assert.equal('10%x', args[3]); } - var m = gm - .resize(58, 50, '%'); - + var m = gm.options({imageMagick}).resize(58, 50, '%'); var args= m.args(); assert.equal('convert', args[0]); assert.equal('-resize', args[2]); diff --git a/test/resizeAndAutoOrientFromBuffer.js b/test/resizeAndAutoOrientFromBuffer.js index 04a56443..c388d12d 100755 --- a/test/resizeAndAutoOrientFromBuffer.js +++ b/test/resizeAndAutoOrientFromBuffer.js @@ -2,7 +2,7 @@ const assert = require('assert'); const path = require('path'); const fs = require('fs') -module.exports = function (_, dir, finish, gm) { +module.exports = function (_, dir, finish, gm, imageMagick) { const original = path.join(dir, 'orientation', 'Portrait_7.jpg'); const result = path.join(dir, 'resizeAutoOrientFromBuffer.png'); @@ -10,30 +10,27 @@ module.exports = function (_, dir, finish, gm) { var buf = fs.readFileSync(original); var m = gm(buf, 'resizefrombuffer.jpg') + .options({imageMagick}) .autoOrient() .resize('20%') - var args = m.args(); - assert.equal('convert', args[0]); - assert.equal('-', args[1]); - assert.equal('-resize', args[2]); - if (m._options.imageMagick) { - assert.equal('20%', args[3]); - } else { - assert.equal('20%x', args[3]); - } + const expectedArgs = imageMagick ? + ['convert', '-', '-auto-orient', '-resize', '20%', '-'] : + ['convert', '-', '-resize', '20%x', '-']; + + assert.deepEqual(m.args(), expectedArgs); if (!gm.integration) return finish(); - size(original, function (err, origSize) { + size(original, imageMagick, function (err, origSize) { if (err) return finish(err); m .write(result, function resizeFromBuffer (err) { if (err) return finish(err); - size(result, function (err, newSize) { + size(result, imageMagick, function (err, newSize) { if (err) return finish(err); assert.ok(origSize.width / 2 >= newSize.width); assert.ok(origSize.height / 2 >= newSize.height); @@ -43,8 +40,8 @@ module.exports = function (_, dir, finish, gm) { }); - function size (file, cb) { - gm(file).identify(function (err, data) { + function size (file, imageMagick, cb) { + gm(file).options({imageMagick}).identify(function (err, data) { if (err) return cb(err); cb(err, data.size); }); diff --git a/test/resizeBuffer.js b/test/resizeBuffer.js index a5087272..e021dafb 100755 --- a/test/resizeBuffer.js +++ b/test/resizeBuffer.js @@ -2,7 +2,7 @@ const assert = require('assert'); const path = require('path'); const fs = require('fs') -module.exports = function (_, dir, finish, gm) { +module.exports = function (_, dir, finish, gm, imageMagick) { var original = path.join(dir, 'original.jpg'); var result = path.join(dir, 'resizeFromBuffer.png'); @@ -10,6 +10,7 @@ module.exports = function (_, dir, finish, gm) { var buf = fs.readFileSync(original); var m = gm(buf, 'resizefrombuffer.jpg') + .options({imageMagick}) .resize('48%') var args = m.args(); @@ -25,14 +26,14 @@ module.exports = function (_, dir, finish, gm) { if (!gm.integration) return finish(); - size(original, function (err, origSize) { + size(original, imageMagick, function (err, origSize) { if (err) return finish(err); m .write(result, function resizeFromBuffer (err) { if (err) return finish(err); - size(result, function (err, newSize) { + size(result, imageMagick, function (err, newSize) { if (err) return finish(err); assert.ok(origSize.width / 2 >= newSize.width); assert.ok(origSize.height / 2 >= newSize.height); @@ -42,8 +43,8 @@ module.exports = function (_, dir, finish, gm) { }); - function size (file, cb) { - gm(file).identify(function (err, data) { + function size (file, imageMagick, cb) { + gm(file).options({imageMagick}).identify(function (err, data) { if (err) return cb(err); cb(err, data.size); }); diff --git a/test/resizeWrong.js b/test/resizeWrong.js index 378c783f..d51abb4c 100644 --- a/test/resizeWrong.js +++ b/test/resizeWrong.js @@ -1,6 +1,6 @@ const path = require('path'); -module.exports = function (_, dir, finish, gm) { +module.exports = function (_, dir, finish, gm, imageMagick) { if (!gm.integration) return finish(); @@ -16,11 +16,12 @@ module.exports = function (_, dir, finish, gm) { index++; } gm(original) + .options({imageMagick}) .resizeExact(width) .write(name, function(err){ if (err) return finish(err); - gm(name) + gm(name).options({imageMagick}) .size(function (err, size) { if (err) return finish(err); if (size.width !== width) { diff --git a/test/scale.js b/test/scale.js index d9f0e298..0df5151a 100644 --- a/test/scale.js +++ b/test/scale.js @@ -1,9 +1,9 @@ const assert = require('assert'); const path = require('path'); -module.exports = function (gm, dir, finish, GM) { +module.exports = function (gm, dir, finish, GM, imageMagick) { - var a = GM('img.png').scale(100); + var a = GM('img.png').options({imageMagick}).scale(100); var args = a.args(); assert.equal('convert', args[0]); assert.equal('-scale', args[2]); @@ -13,21 +13,19 @@ module.exports = function (gm, dir, finish, GM) { assert.equal('100x', args[3]); } - var a = GM('img.png').scale(100, 200, '%'); + var a = GM('img.png').options({imageMagick}).scale(100, 200, '%'); var args = a.args(); assert.equal('convert', args[0]); assert.equal('-scale', args[2]); assert.equal('100x200%', args[3]); - var a = GM('img.png').scale(100, '200%'); + var a = GM('img.png').options({imageMagick}).scale(100, '200%'); var args = a.args(); assert.equal('convert', args[0]); assert.equal('-scale', args[2]); assert.equal('100x200%', args[3]); - var m = gm - .scale(100, 100); - + var m = gm.options({imageMagick}).scale(100, 100); var args = m.args(); assert.equal('convert', args[0]); assert.equal('-scale', args[2]); diff --git a/test/selectFrame.js b/test/selectFrame.js index ce74b186..0d65b7c0 100644 --- a/test/selectFrame.js +++ b/test/selectFrame.js @@ -1,14 +1,14 @@ const assert = require('assert'); const path = require('path'); -module.exports = function (_, dir, finish, gm) { +module.exports = function (_, dir, finish, gm, imageMagick) { const gifPath = path.join(dir, 'original.gif[0]'); var m = gm(gifPath); if (!gm.integration) return finish(); - m.identify('%#', function (err, hash1) { + m.options({imageMagick}).identify('%#', function (err, hash1) { if (err) return finish(err); m.selectFrame(2).identify('%#', function (err, hash2) { diff --git a/test/streamIn.js b/test/streamIn.js index 4caa7895..003565de 100644 --- a/test/streamIn.js +++ b/test/streamIn.js @@ -2,11 +2,11 @@ const assert = require('assert'); const path = require('path'); const fs = require('fs'); -module.exports = function (_, dir, finish, gm) { +module.exports = function (_, dir, finish, gm, imageMagick) { const originalPath = path.join(dir, 'original.jpg'); const stream = fs.createReadStream(originalPath); - const m = gm(stream, "original.jpg"); + const m = gm(stream, "original.jpg").options({imageMagick}); assert.equal(stream, m.sourceStream); assert.equal('original.jpg', m.source); diff --git a/test/streamInGetter.js b/test/streamInGetter.js index 554364e4..08c2ea89 100644 --- a/test/streamInGetter.js +++ b/test/streamInGetter.js @@ -1,12 +1,13 @@ const path = require('path'); const fs = require('fs'); -module.exports = function (_, dir, finish, gm) { +module.exports = function (_, dir, finish, gm, imageMagick) { if (!gm.integration) return finish(); const originalPath = path.join(dir, 'original.jpg'); gm(fs.createReadStream(originalPath)) + .options({imageMagick}) .size({bufferStream: true}, function (err, size) { const destPath = path.join(dir, 'streamInGetter.png'); this.write(destPath, function streamInGetter (err){ diff --git a/test/streamInOut.js b/test/streamInOut.js index fdaafe82..af33fbeb 100644 --- a/test/streamInOut.js +++ b/test/streamInOut.js @@ -1,13 +1,14 @@ const path = require('path'); const fs = require('fs'); -module.exports = function (_, dir, finish, gm) { +module.exports = function (_, dir, finish, gm, imageMagick) { if (!gm.integration) return finish(); const originalPath = path.join(dir, 'original.jpg'); gm(fs.createReadStream(originalPath), "original.jpg") + .options({imageMagick}) .stream(function streamOut (err, stdout, stderr) { if (err) return finish(err); const destPath = path.join(dir, 'streamInOut.jpg'); diff --git a/test/streamOutFormat.js b/test/streamOutFormat.js index 71a81957..3f50586d 100644 --- a/test/streamOutFormat.js +++ b/test/streamOutFormat.js @@ -2,7 +2,7 @@ const assert = require('assert') const path = require('path'); const fs = require('fs'); -module.exports = function (gm, dir, finish, GM) { +module.exports = function (gm, dir, finish, GM, imageMagick) { if (!GM.integration) return finish(); @@ -38,7 +38,7 @@ module.exports = function (gm, dir, finish, GM) { function checkOutputFormat(done) { var stream = gm.stream('PNG') stream.on('error', done) - GM(stream).format(function (err, value) { + GM(stream).options({imageMagick}).format(function (err, value) { if (err) return done(err) diff --git a/test/strip.js b/test/strip.js index 7f7c0cb7..b4d3b700 100644 --- a/test/strip.js +++ b/test/strip.js @@ -16,7 +16,7 @@ module.exports = function (gm, dir, finish, GM) { return finish(); const destPath = path.join(dir, 'strip.png'); - m.write(destPath, function edge (err) { + m.write(destPath, function strip (err) { finish(err); }); } diff --git a/test/subclass.js b/test/subclass.js index 3d251f9b..18f3924e 100644 --- a/test/subclass.js +++ b/test/subclass.js @@ -1,7 +1,7 @@ const assert = require('assert'); const path = require('path'); -module.exports = function (_, dir, finish, gm) { +module.exports = function (_, dir, finish, gm, imageMagick) { assert.equal('gm', gm('test').constructor.name); assert.equal(undefined, gm.prototype._options.imageMagick); @@ -25,7 +25,8 @@ module.exports = function (_, dir, finish, gm) { const sourcePath = path.join(dir, 'photo.JPG'); const destPath = path.join(dir, 'subclass.png'); - gm(sourcePath) + const m = gm.subClass({ imageMagick }); + m(sourcePath) .thumb(50, 80, destPath, function subthumb (err) { if (err) return finish(err); finish(); diff --git a/test/timeout.js b/test/timeout.js index ab416d20..3e0792f7 100644 --- a/test/timeout.js +++ b/test/timeout.js @@ -1,7 +1,7 @@ const assert = require('assert'); const path = require('path'); -module.exports = function (img, dir, finish, gm) { +module.exports = function (img, dir, finish, gm, imageMagick) { assert.equal(undefined, gm.prototype._options.timeout); assert.equal(undefined, img._options.timeout); @@ -18,7 +18,7 @@ module.exports = function (img, dir, finish, gm) { const sourcePath = path.join(dir, 'photo.JPG'); const timeoutPath = path.join(dir, 'timeout.png'); - gm(sourcePath).options({ timeout: 1 }) + gm(sourcePath).options({ timeout: 1, imageMagick }) .thumb(50, 80, timeoutPath, function subthumb (err) { assert.ok(err, "Expecting a timeout error"); noTimeout(); @@ -26,7 +26,7 @@ module.exports = function (img, dir, finish, gm) { function noTimeout() { - gm(sourcePath).options({ timeout: 0 }) + gm(sourcePath).options({ timeout: 0, imageMagick }) .thumb(50, 80, timeoutPath, function subthumb (err) { finish(err); }); diff --git a/test/webp.js b/test/webp.js index 5cb7b155..0279fbea 100644 --- a/test/webp.js +++ b/test/webp.js @@ -2,7 +2,7 @@ const assert = require('assert'); const path = require('path'); const fs = require('fs') -module.exports = function (_, dir, finish, gm, im) { +module.exports = function (_, dir, finish, gm, imageMagick) { if (!gm.integration) return finish() // Don't know how to install IM with WEBP on ubuntu @@ -12,7 +12,7 @@ module.exports = function (_, dir, finish, gm, im) { // if (!im) return finish() gm = gm.subClass({ - imageMagick: true + imageMagick }) const imagePath = path.join(dir, 'original.png'); From bf11965635a41d734f480887a67c0960b057664e Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Wed, 21 Sep 2022 06:53:05 -0700 Subject: [PATCH 63/64] docs https://github.com/aheckmann/gm/pull/821 Co-authored-by: ash --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 71859843..e16fdc29 100644 --- a/README.md +++ b/README.md @@ -631,6 +631,15 @@ http://github.com/quiiver/magickal-node ## Plugins [https://github.com/aheckmann/gm/wiki](https://github.com/aheckmann/gm/wiki) +## Tests +`npm test` + +To run a single test: + +``` +npm test -- alpha.js +``` + ## License (The MIT License) From 6ad6cce4e807ce5a9a476a783d264c9d3bb5b571 Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Wed, 21 Sep 2022 08:54:44 -0700 Subject: [PATCH 64/64] release 1.25.0 --- History.md | 6 ++++++ package.json | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/History.md b/History.md index 32c50943..66499e0a 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,9 @@ +1.25.0 / 2022-09-21 + +* fixed: windows support #846, #774, #594, #524, #528, #559, #652, #682 [piotr-cz](https://github.com/piotr-cz) +* docs; improvements from #821 [agokhale](https://github.com/agokhale) +* docs; improvements #801 [aarongarciah](https://github.com/aarongarciah) + 1.24.0 / 2022-09-18 * fixed: infering format of buffered or streamed ico files #429 freund17 diff --git a/package.json b/package.json index 48988a4f..73c866a6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "gm", "description": "GraphicsMagick and ImageMagick for node.js", - "version": "1.24.0", + "version": "1.25.0", "author": "Aaron Heckmann ", "keywords": [ "graphics", @@ -47,4 +47,4 @@ "cross-spawn": "^4.0.0", "debug": "^3.1.0" } -} \ No newline at end of file +}