From 05f90eff9bc4d0f9917887728642a18e0d659c27 Mon Sep 17 00:00:00 2001 From: Gal Jozsef Date: Fri, 5 Aug 2016 14:53:30 +0200 Subject: [PATCH] fix (identify) parse could resolve multiline value like: ``` Clipping path: ``` --- imagemagick.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/imagemagick.js b/imagemagick.js index b846c0c..49e6401 100644 --- a/imagemagick.js +++ b/imagemagick.js @@ -97,21 +97,23 @@ function exec2(file, args /*, options, callback */) { return child; }; - function parseIdentify(input) { var lines = input.split("\n"), prop = {}, props = [prop], prevIndent = 0, indents = [indent], - currentLine, comps, indent, i; + currentLine, comps, indent, i, compName; lines.shift(); //drop first line (Image: name.jpg) for (i in lines) { currentLine = lines[i]; indent = currentLine.search(/\S/); - if (indent >= 0) { + + if (indent < prevIndent && indent === 0) { + prop[compName] += currentLine; + } else if (indent >= 0) { comps = currentLine.split(': '); if (indent > prevIndent) indents.push(indent); while (indent < prevIndent && props.length) { @@ -119,11 +121,13 @@ function parseIdentify(input) { prop = props.pop(); prevIndent = indents[indents.length - 1]; } + if (comps.length < 2) { props.push(prop); prop = prop[currentLine.split(':')[0].trim().toLowerCase()] = {}; - } else { - prop[comps[0].trim().toLowerCase()] = comps[1].trim() + } else { + compName = comps[0].trim().toLowerCase(); + prop[compName] = comps[1].trim(); } prevIndent = indent; }