Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gm

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gm - npm Package Compare versions

Comparing version 1.24.0 to 1.25.0

6

History.md

@@ -0,1 +1,7 @@

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

@@ -2,0 +8,0 @@

59

lib/command.js

@@ -38,3 +38,3 @@

}
function streamToUnemptyBuffer(stream, callback) {

@@ -49,3 +49,2 @@ var done = false

stream.on('end', function () {
var result, err;
if (done)

@@ -55,10 +54,10 @@ 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);
}

@@ -202,3 +201,3 @@ })

* @param {Boolean} shouldBuffer
* @param {Function} callback, signature (err, stdout, stderr) -> *
* @param {Function} callback, signature (err, stdout, stderr) -> *
* @return {Object} gm

@@ -210,6 +209,25 @@ * @TODO refactor this mess

var appPath = this._options.appPath || '';
var bin = this._options.imageMagick
? appPath + args.shift()
: appPath + 'gm'
var bin
// Resolve executable
switch (this._options.imageMagick) {
// legacy behavior
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(' ')

@@ -225,4 +243,3 @@ , self = this

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"));
}

@@ -235,3 +252,3 @@ try {

proc.stdin.once('error', cb);
proc.on('error', function(err){

@@ -265,4 +282,3 @@ if (err.code === 'ENOENT') {

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."));
}

@@ -308,2 +324,3 @@

proc.on('close', onExit = function (code, signal) {
let err;
if (code !== 0 || signal !== null) {

@@ -328,4 +345,4 @@ err = new Error('Command failed: ' + stderr);

if (args[0] !== 'identify' && bin !== 'identify') {
self._in = [];
self._out = [];
self._in = [];
self._out = [];
}

@@ -336,4 +353,4 @@ 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);

@@ -340,0 +357,0 @@ if (proc.exitCode === null) {

// compare
var spawn = require('cross-spawn');
var debug = require('debug')('gm');
var utils = require('./utils');

@@ -25,9 +27,24 @@ /**

var appPath = this._options && this._options.appPath || '';
var bin = isImageMagick
? appPath + 'compare'
: appPath + 'gm'
var args = ['-metric', 'mse', orig, compareTo]
if (!isImageMagick) {
var args = ['-metric', 'mse', orig, compareTo];
// Resove executable
let bin;
switch (isImageMagick) {
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 tolerance = 0.4;

@@ -60,3 +77,3 @@ // outputting the diff image

}
if (typeof options.tolerance != 'undefined') {

@@ -67,3 +84,3 @@ if (typeof options.tolerance !== 'number') {

tolerance = options.tolerance;
}
}
} else {

@@ -82,2 +99,5 @@ // For ImageMagick diff file is required but we don't care about it, so null it out

var cmd = bin + ' ' + args.map(utils.escape).join(' ')
debug(cmd);
var proc = spawn(bin, args);

@@ -84,0 +104,0 @@ var stdout = '';

{
"name": "gm",
"description": "GraphicsMagick and ImageMagick for node.js",
"version": "1.24.0",
"version": "1.25.0",
"author": "Aaron Heckmann <aaron.heckmann+github@gmail.com>",

@@ -31,3 +31,6 @@ "keywords": [

"scripts": {
"test": "make test;"
"security": "npm audit",
"test": "npm run security && npm run test-integration",
"test-integration": "node test/ --integration",
"test-unit": "node test/"
},

@@ -34,0 +37,0 @@ "repository": {

@@ -27,15 +27,27 @@

Subclass `gm` to enable ImageMagick
Subclass `gm` to enable [ImageMagick 7+](https://imagemagick.org/script/porting.php)
```js
var fs = require('fs')
, gm = require('gm').subClass({imageMagick: true});
const fs = require('fs')
const gm = require('gm').subClass({ imageMagick: '7+' });
```
// resize and remove EXIF profile data
gm('/path/to/my/img.jpg')
.resize(240, 240)
...
Or, to enable ImageMagick legacy mode (for ImageMagick version < 7)
```js
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

@@ -531,3 +543,3 @@

##compare
## compare

@@ -581,3 +593,3 @@ Graphicsmagicks `compare` command is exposed through `gm.compare()`. This allows us to determine if two images can be considered "equal".

##composite
## composite

@@ -599,3 +611,3 @@ 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.

##montage
## montage

@@ -626,2 +638,11 @@ 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.

## Tests
`npm test`
To run a single test:
```
npm test -- alpha.js
```
## License

@@ -628,0 +649,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc