Sobesednik / node-exiftool

A Node.js interface to exiftool command-line application.
MIT License
91 stars 15 forks source link

Issue with spaces in extra arguments? #43

Open digitalnature opened 6 years ago

digitalnature commented 6 years ago

it looks like some arguments are not supported, like "c" (coordFormat)

ep.readMetadata(path, ['j', 'n', 'c "%d %d %.8f"', 'fast2']).then(...

will make exiftool believe that %d is a file and throw a 'File not found: %d' error

digitalnature commented 6 years ago

The problem seems to be the splitting by space from the getArgs function: https://github.com/Sobesednik/node-exiftool/blob/e4a8fb7c129de38d7a87f02a471ec17577af4f15/src/lib.js#L48

digitalnature commented 6 years ago

Replacing it with this fixes it:

        [].concat(acc, noSplit ? [arg] : arg.match(/\\?.|^$/g).reduce((p, c) => {
            if(c === '"'){
                p.quote ^= 1;
            }else if(!p.quote && c === ' '){
                p.a.push('');
            }else{
                p.a[p.a.length - 1] += c.replace(/\\(.)/, "$1");
            }
            return  p;
        }, {a: ['']}).a)
ChenAlon commented 4 years ago

I'm using it like this and it's working: ep.readMetadata(path, ['json', 'd %s', 'c %.6f', 'Orientation#', 'all'])