Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pasring xml values in identify #93

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 16 additions & 8 deletions imagemagick.js
Expand Up @@ -110,6 +110,10 @@ function parseIdentify(input) {


for (i in lines) { for (i in lines) {
currentLine = lines[i]; currentLine = lines[i];
// Skip xml multiline value. Found on http://beta.images.theglobeandmail.com/media/mobile/images/iphone.icon.highres.png.
if (/\s*</i.test(currentLine)) {
continue;
}
indent = currentLine.search(/\S/); indent = currentLine.search(/\S/);
if (indent >= 0) { if (indent >= 0) {
comps = currentLine.split(': '); comps = currentLine.split(': ');
Expand Down Expand Up @@ -152,14 +156,18 @@ exports.identify = function(pathOrArgs, callback) {
if (isCustom) { if (isCustom) {
result = stdout; result = stdout;
} else { } else {
result = parseIdentify(stdout); try {
geometry = result['geometry'].split(/x/); result = parseIdentify(stdout);

geometry = result['geometry'].split(/x/);
result.format = result.format.match(/\S*/)[0]
result.width = parseInt(geometry[0]); result.format = result.format.match(/\S*/)[0]
result.height = parseInt(geometry[1]); result.width = parseInt(geometry[0]);
result.depth = parseInt(result.depth); result.height = parseInt(geometry[1]);
if (result.quality !== undefined) result.quality = parseInt(result.quality) / 100; result.depth = parseInt(result.depth);
if (result.quality !== undefined) result.quality = parseInt(result.quality) / 100;
} catch (ex) {
return callback(ex);
}
} }
} }
callback(err, result); callback(err, result);
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{ "name" : "imagemagick" { "name" : "imagemagick"
, "description" : "A wrapper around the imagemagick cli" , "description" : "A wrapper around the imagemagick cli"
, "version" : "0.1.3" , "version" : "0.1.4"
, "author" : "Rasmus Andersson <http://rsms.me/>" , "author" : "Rasmus Andersson <http://rsms.me/>"
, "licenses" : ["MIT"] , "licenses" : ["MIT"]
, "repository" : { "type" : "git" , "repository" : { "type" : "git"
Expand Down