MCPcopy
hub / github.com/rsms/node-imagemagick / parseIdentify

Function parseIdentify

imagemagick.js:101–132  ·  view source on GitHub ↗
(input)

Source from the content-addressed store, hash-verified

99
100
101function parseIdentify(input) {
102 var lines = input.split("\n"),
103 prop = {},
104 props = [prop],
105 prevIndent = 0,
106 indents = [indent],
107 currentLine, comps, indent, i;
108
109 lines.shift(); //drop first line (Image: name.jpg)
110
111 for (i in lines) {
112 currentLine = lines[i];
113 indent = currentLine.search(/\S/);
114 if (indent >= 0) {
115 comps = currentLine.split(': ');
116 if (indent > prevIndent) indents.push(indent);
117 while (indent < prevIndent && props.length) {
118 indents.pop();
119 prop = props.pop();
120 prevIndent = indents[indents.length - 1];
121 }
122 if (comps.length < 2) {
123 props.push(prop);
124 prop = prop[currentLine.split(':')[0].trim().toLowerCase()] = {};
125 } else {
126 prop[comps[0].trim().toLowerCase()] = comps[1].trim()
127 }
128 prevIndent = indent;
129 }
130 }
131 return prop;
132};
133
134exports.identify = function(pathOrArgs, callback) {
135 var isCustom = Array.isArray(pathOrArgs),

Callers 1

imagemagick.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected