diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index c3ef35c..81f7b37 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 70cb3ad..4133238 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 8048ec3..17c98d5 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 790ac04..dc0cdb4 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 b179bc1..2e88952 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 dfc15f6..d980439 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 dd8a7ed..115884b 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 32dfc14..5e34bda 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 161076c..67051cf 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 1976b20..b5603f6 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 c78bb40..cbeb07e 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 aebb24a..8255087 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 618b89b..5bc004c 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 1502cc7..4a49ba7 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 13a868e..8d97469 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 ac11e45..07195eb 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 89c651b..ceab256 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 27e58a6..0000000 --- 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 ec7cc72..67b9598 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 d093bd1..46e04c7 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 1bb5d6d..c5ab2dc 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 4dbbbcd..3df00f3 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 9f95a5a..793f43f 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 0fd6daf..6a3fcb6 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 23d9dfb..30f5e54 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 73cc619..89fecf8 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 f197b17..4b558b2 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 422d6eb..2a48032 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 d67d3b3..89ee1b0 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 3e16ed1..d3c3d7b 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 90f773a..6d79c1e 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 af1f113..39f0508 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 cbbc429..20b17cb 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 b73ffd2..1f4dd1e 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 f09e3cb..89e26a7 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 aa31cb2..21bec8a 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 72c587b..14c6301 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 fae94c6..af756cc 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 04a5644..c388d12 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 a508727..e021daf 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 378c783..d51abb4 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 d9f0e29..0df5151 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 ce74b18..0d65b7c 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 4caa789..003565d 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 554364e..08c2ea8 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 fdaafe8..af33fbe 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 71a8195..3f50586 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 7f7c0cb..b4d3b70 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 3d251f9..18f3924 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 ab416d2..3e0792f 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 5cb7b15..0279fbe 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');