diff --git a/imagemagick.js b/imagemagick.js index b846c0c..3322847 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(': '); @@ -152,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); 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"