From a3b65a0630c965054898b4f5e9ba0d7afa6e28ee Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Wed, 22 May 2013 17:55:27 +0300 Subject: [PATCH 1/3] Fix parseIdentify when multiline xml value found. Error image: http://beta.images.theglobeandmail.com/media/mobile/images/iphone.icon.highres.png --- imagemagick.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/imagemagick.js b/imagemagick.js index b846c0c..18a1e25 100644 --- a/imagemagick.js +++ b/imagemagick.js @@ -110,6 +110,10 @@ function parseIdentify(input) { for (i in lines) { currentLine = lines[i]; + // Skip xml multiline value. Found on http://beta.images.theglobeandmail.com/media/mobile/images/iphone.icon.highres.png. + if (/\s*= 0) { comps = currentLine.split(': '); From 4272677804795d94f5e5d1e4bce20c7d5973e92d Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Wed, 22 May 2013 17:56:00 +0300 Subject: [PATCH 2/3] Update package version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dfcb83b..3274ed3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name" : "imagemagick" , "description" : "A wrapper around the imagemagick cli" -, "version" : "0.1.3" +, "version" : "0.1.4" , "author" : "Rasmus Andersson " , "licenses" : ["MIT"] , "repository" : { "type" : "git" From c1a13adfccd5143ef60b80242be5821b5472dac7 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Wed, 22 May 2013 18:05:50 +0300 Subject: [PATCH 3/3] Catch async exceptions while identifing image. --- imagemagick.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/imagemagick.js b/imagemagick.js index 18a1e25..3322847 100644 --- a/imagemagick.js +++ b/imagemagick.js @@ -156,14 +156,18 @@ exports.identify = function(pathOrArgs, callback) { if (isCustom) { result = stdout; } else { - result = parseIdentify(stdout); - geometry = result['geometry'].split(/x/); - - result.format = result.format.match(/\S*/)[0] - result.width = parseInt(geometry[0]); - result.height = parseInt(geometry[1]); - result.depth = parseInt(result.depth); - if (result.quality !== undefined) result.quality = parseInt(result.quality) / 100; + try { + result = parseIdentify(stdout); + geometry = result['geometry'].split(/x/); + + result.format = result.format.match(/\S*/)[0] + result.width = parseInt(geometry[0]); + result.height = parseInt(geometry[1]); + result.depth = parseInt(result.depth); + if (result.quality !== undefined) result.quality = parseInt(result.quality) / 100; + } catch (ex) { + return callback(ex); + } } } callback(err, result);