Socket
Socket
Sign inDemoInstall

gm

Package Overview
Dependencies
4
Maintainers
4
Versions
64
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.17.0 to 1.18.1

lib/montage.js

20

History.md

@@ -0,1 +1,21 @@

1.18.1 / 2015-05-18
* changed: Added io.js support [rwky](https://github.com/rwky)
1.18.0 / 2015-05-18
* changed: Removed support for node 0.8 and added support for 0.12 [rwky](https://github.com/rwky)
* changed: Listen to stdin error event for spawn errors [kapouer](https://github.com/kapouer)
* changed: Improved error handling when gm isn't installed [FreshXOpenSource](https://github.com/FreshXOpenSource)
* changed: Allow append method to use an array of arguments [emohacker](https://github.com/emohacker)
* changed: appPath option now specifies full path to gm binary John Borkowski
* changed: Ignore warning messages for identify [asrail](https://github.com/asrail)
* added: Montage method [donaldpcook](https://github.com/donaldpcook)
* added: Progressive option to thumb [mohebifar](https://github.com/mohebifar)
* added: Native gm auto-orient for use with gm >= 1.3.18 [bog](https://github.com/bog)
* added: Timeout support by passing the timeout option in milliseconds [marcbachmann](https://github.com/marcbachmann)
* fixed: density when using ImageMagick [syzer](https://github.com/syzer)
* fixed: resize behaviour for falsy values [adius](https://github.com/adius)
1.17.0 / 2014-10-28

@@ -2,0 +22,0 @@ ==================

1

index.js

@@ -120,2 +120,3 @@

require("./lib/composite")(gm.prototype);
require("./lib/montage")(gm.prototype);

@@ -122,0 +123,0 @@ /**

46

lib/args.js

@@ -6,3 +6,3 @@ /**

var argsToArray = require('./utils').argsToArray;
var isUtil = require('./utils').isUtil;
/**

@@ -37,2 +37,7 @@ * Extend proto

proto.alpha = function alpha (type) {
if (!this._options.imageMagick) return new Error('Method -alpha is not supported by GraphicsMagick');
return this.out('-alpha', type);
}
/**

@@ -57,4 +62,5 @@ * Appends images to the list of "source" images.

* img.append(img).background('#222) gm convert src img -background #222 +append
*
* @param {String} [img]
* img.append([img1,img2...],true)
* @param {String} or {Array} [img]
* @param {Boolean} [ltr]

@@ -80,9 +86,16 @@ * @see http://www.graphicsmagick.org/GraphicsMagick.html#details-append

var arg = arguments[i];
switch (typeof arg) {
case 'boolean':
switch (isUtil(arg)) {
case 'Boolean':
this._append.ltr = arg;
break;
case 'string':
case 'String':
this._append.push(arg);
break;
case 'Array':
for(var j=0,len=arg.length;j<len;j++){
if(isUtil(arg[j]) == 'String'){
this._append.push(arg[j]);
}
}
break;
}

@@ -701,10 +714,16 @@ }

options = options || "";
var geometry;
if (w && h) {
var geometry,
wIsValid = Boolean(w || w === 0),
hIsValid = Boolean(h || h === 0);
if (wIsValid && hIsValid) {
geometry = w + "x" + h + options
} else if (w && !h) {
} else if (wIsValid) {
// GraphicsMagick requires <width>x<options>, ImageMagick requires <width><options>
geometry = (this._options.imageMagick) ? w + options : w + 'x' + options;
} else if (!w && h) {
geometry = (this._options.imageMagick) ? w + options : w +
'x' + options;
} else if (hIsValid) {
geometry = 'x' + h + options
} else {
return this
}

@@ -737,2 +756,7 @@

proto.density = function density (w, h) {
if (w && !h && this._options.imageMagick) {
// GraphicsMagick requires <width>x<height>y, ImageMagick may take dpi<resolution>
// recommended 300dpi for higher quality
return this.in("-density", w);
}
return this.in("-density", w +"x"+ h);

@@ -739,0 +763,0 @@ }

@@ -6,3 +6,2 @@

var exec = require('child_process').exec;
var spawn = require('child_process').spawn;

@@ -12,11 +11,4 @@ var utils = require('./utils');

var series = require('array-series');
var PassThrough = require('stream').PassThrough;
/*
* Creates a pass through stream.
* We need to fallback to the `through` lib for node 0.8 support
* as PassThrough was added in node 0.10.
*/
var PassThrough = require('stream').PassThrough || require('through');
/**

@@ -218,7 +210,9 @@ * Error messaging.

? appPath + args.shift()
: 'gm'
: appPath + 'gm'
var cmd = bin + ' ' + args.map(utils.escape).join(' ')
, self = this
, proc, err;
, proc, err
, timeout = parseInt(this._options.timeout)
, timeoutId;

@@ -232,3 +226,15 @@ debug(cmd);

}
proc.stdin.once('error', cb);
if (timeout) {
timeoutId = setTimeout(function(){
err = new Error('gm() resulted in a timeout.');
cb(err);
if (proc.connected) {
proc.stdin.pause();
proc.kill();
}
}, timeout);
}
if (self.sourceBuffer) {

@@ -291,3 +297,9 @@ proc.stdin.write(this.sourceBuffer);

proc.on('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);
}
});
} else {

@@ -301,2 +313,3 @@ cb(null, proc.stdout, proc.stderr, cmd);

if (cb.called) return;
if (timeoutId) clearTimeout(timeoutId);
cb.called = 1;

@@ -303,0 +316,0 @@ if (args[0] !== 'identify' && bin !== 'identify') {

// composite
var exec = require('child_process').exec;
var utils = require('./utils');

@@ -5,0 +4,0 @@

@@ -25,4 +25,4 @@

// so does graphicsmagick, but in 1.3.18.
// apt doesn't release this version yet.
if (this._options.imageMagick) {
// nativeAutoOrient option enables this if you know you have >= 1.3.18
if (this._options.nativeAutoOrient || this._options.imageMagick) {
this.out('-auto-orient');

@@ -29,0 +29,0 @@ this.strip();

@@ -8,3 +8,3 @@

proto.thumb = function thumb (w, h, name, quality, align, callback) {
proto.thumb = function thumb (w, h, name, quality, align, progressive, callback) {
var self = this

@@ -19,2 +19,3 @@ , args = Array.prototype.slice.call(arguments);

align = args.shift() || 'topleft';
var interlace = args.shift() ? 'Line' : 'None';

@@ -67,2 +68,3 @@ self.size(function (err, size) {

.crop(w, h, xoffset, yoffset)
.interlace(interlace)
.noProfile()

@@ -69,0 +71,0 @@ .write(name, function () {

@@ -207,3 +207,3 @@ /**

if ('Image' == key) continue;
if ('Image' == key || 'Warning' == key) continue;

@@ -210,0 +210,0 @@ var val = res[3] ? res[3].trim() : null;

@@ -27,2 +27,18 @@

return arr;
};
};
exports.isUtil = function (v) {
var ty = 'object';
switch (Object.prototype.toString.call(v)) {
case '[object String]':
ty = 'String';
break;
case '[object Array]':
ty = 'Array';
break;
case '[object Boolean]':
ty = 'Boolean';
break;
}
return ty;
}
{
"name": "gm",
"description": "GraphicsMagick and ImageMagick for node.js",
"version": "1.17.0",
"version": "1.18.1",
"author": "Aaron Heckmann <aaron.heckmann+github@gmail.com>",

@@ -18,3 +18,3 @@ "keywords": [

"engines": {
"node": ">= 0.8.0"
"node": ">= 0.10.0"
},

@@ -40,11 +40,10 @@ "bugs": {

"devDependencies": {
"gleak": "0.4.0",
"async": "~0.2.7"
"gleak": "~0.5.0",
"async": "~0.9.0"
},
"dependencies": {
"debug": "0.7.0",
"array-series": "~0.1.0",
"array-parallel": "~0.1.0",
"through": "~2.3.1"
"debug": "~2.2.0",
"array-series": "~0.1.5",
"array-parallel": "~0.1.3"
}
}

@@ -27,11 +27,10 @@

Just pass the option `{imageMagick: true}` to enable ImageMagick
Subclass `gm` to enable ImageMagick
```js
var fs = require('fs')
, gm = require('./gm');
, gm = require('./gm').subClass({imageMagick: true});
// resize and remove EXIF profile data
gm('/path/to/my/img.jpg')
.options({imageMagick: true})
.resize(240, 240)

@@ -155,3 +154,3 @@ ...

var readStream = fs.createReadStream('/path/to/my/img.jpg');
gm(readStream, 'img.jpg')
gm(readStream)
.resize('200', '200')

@@ -169,3 +168,3 @@ .stream(function (err, stdout, stderr) {

var readStream = fs.createReadStream('/path/to/my/img.jpg');
gm(readStream, 'img.jpg')
gm(readStream)
.size({bufferStream: true}, function(err, size) {

@@ -569,2 +568,19 @@ this.resize(size.width / 2, size.height / 2)

##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.
Currently, `gm.montage()` only accepts file paths.
gm.montage(other)
```js
gm('/path/to/image.jpg')
.montage('/path/to/second_image.jpg')
.geometry('+100+150')
.write('/path/to/montage.png', function(err) {
if(!err) console.log("Written montage image.");
});
```
## Contributors

@@ -571,0 +587,0 @@ [https://github.com/aheckmann/gm/contributors](https://github.com/aheckmann/gm/contributors)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc