Sobesednik / node-exiftool

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

Encoding problem #20

Closed neojski closed 7 years ago

neojski commented 7 years ago

I was trying node-exiftool on windows in cygwin but had I experience some problems with encoding. Please note that dist-exiftool works fine whilst node-exiftool does not:

const execFile = require('child_process').execFile;
const exiftoolBin = require('dist-exiftool');
const exiftool = require('node-exiftool')

const file = 'zdjęcie.jpg';

execFile(exiftoolBin, ['-j', file], (error, stdout, stderr) => {
        if (error) {
                console.error(`exec error: ${error}`);
                return;
        }
        console.log('raw:');
        console.log(stdout);
});

const ep = new exiftool.ExiftoolProcess(exiftoolBin)
ep.open()
        .then(() => ep.readMetadata(file))
        .then(result => {
                console.log('advanced:');
                console.log(result);
        })
        .then(() => ep.close());

raw: [{ "SourceFile": "zdj?cie.jpg", "ExifToolVersion": 10.33, "FileName": "zdj?cie.jpg", "Directory": ".", "Warning": "FileName encoding not specified", ... }]

advanced: { data: null, error: 'File not found: zdjęcie.jpg' }

Also, please note that running exiftool directly doesn't print garbled file name:

$ ./node_modules/exiftool.pl/vendor/exiftool zdjęcie.jpg
ExifTool Version Number         : 10.33
File Name                       : zdjęcie.jpg
Directory                       : .
...
z-vr commented 7 years ago

@neojski you are right, on Windows it cannot read the file: https://github.com/Sobesednik/node-exiftool/pull/24

z-vr commented 7 years ago

You have to pass ['charset filename=utf8'] as argument, e.g., ep.readMetadata('zdjęcie.jpg', ['charset filename=utf8'])

passing build test

http://www.sno.phy.queensu.ca/~phil/exiftool/faq.html#Q18 http://u88.n24.queensu.ca/exiftool/forum/index.php?topic=6721.0

neojski commented 7 years ago

I don't have a windows machine on hand now but this looks pretty convincing. Thanks!

z-vr commented 7 years ago

@neojski cool thanks for raising the issue! 👍