From 66cc1124e99d89e6e9484d3088d512cf925abd20 Mon Sep 17 00:00:00 2001 From: Roman Rosluk Date: Tue, 22 Sep 2015 10:28:44 +0200 Subject: [PATCH 1/2] Node crush on no result geometry --- imagemagick.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/imagemagick.js b/imagemagick.js index b846c0c..05e6feb 100644 --- a/imagemagick.js +++ b/imagemagick.js @@ -147,18 +147,25 @@ exports.identify = function(pathOrArgs, callback) { callback = pathOrArgs; } var proc = exec2(exports.identify.path, args, {timeout:120000}, function(err, stdout, stderr) { - var result, geometry; + var result; if (!err) { if (isCustom) { result = stdout; } else { result = parseIdentify(stdout); - geometry = result['geometry'].split(/x/); + + if (result.format) { + result.format = result.format.match(/\S*/)[0]; + } - result.format = result.format.match(/\S*/)[0] - result.width = parseInt(geometry[0]); - result.height = parseInt(geometry[1]); - result.depth = parseInt(result.depth); + if (result['geometry']) { + var geometry = result['geometry'].split(/x/); + result.width = parseInt(geometry[0]); + result.height = parseInt(geometry[1]); + } + if (result.depth) { + result.depth = parseInt(result.depth); + } if (result.quality !== undefined) result.quality = parseInt(result.quality) / 100; } } From 7a0ea4862a6fc45f0b7e7edadd507ffb020b77f6 Mon Sep 17 00:00:00 2001 From: Roman Rosluk Date: Fri, 6 Nov 2015 09:50:50 +0100 Subject: [PATCH 2/2] Space --- imagemagick.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imagemagick.js b/imagemagick.js index 05e6feb..1d29b1e 100644 --- a/imagemagick.js +++ b/imagemagick.js @@ -153,7 +153,7 @@ exports.identify = function(pathOrArgs, callback) { result = stdout; } else { result = parseIdentify(stdout); - + if (result.format) { result.format = result.format.match(/\S*/)[0]; }