exiftool-rb / exiftool.rb

Ruby exiftool wrapper that is simple, correct, and supports multiget
71 stars 20 forks source link

Gem doesn't work on Windows #31

Open sroller opened 1 year ago

sroller commented 1 year ago

The gem doesn't recognize the exiftool command even when it's installed. That's because Windows' null device doesn't follow the POSIX rules.

I added the gem 'os' to the file exiftool.rb.

require 'os'

I changed line #60 to

cmd = "#{self.class.command} #{exiftool_opts} -j -coordFormat \"%.8f\" #{escaped_filenames} 2> #{OS.dev_null}"

and that did it for me.

sroller commented 1 year ago

Turns out there are other more issues to solve. The Shellwords.escape method doesn't work as expected either. The best way I found was to put each file within "A filename with spaces.jpg". That has to be followed by a change from join(' ') to join('" "') and additional quotes around the list of filenames in the cmd varialble.

The output of the exiftool on Windows doesn't match what's in the expected folder. Therefore the tests aren't green. I hoped I could send a merge request, but it's too early. it's messy :-(.

Do you have routine to turn the output of exiftool into yaml format for the expect files?

morozgrafix commented 1 year ago

@sroller thanks for digging into it. I haven't touched the code for this gem in a while, with exception of the minor housekeeping tasks. I will try to find some time to look into exiftool output -> yaml question and get back to you. Please keep me posted on developments on your side of things and I'm happy to discuss potential changes.

morozgrafix commented 1 year ago

I believe that additional output key/value pairs that you may see on Windows can be added to keys to be ignored during tests in exiftool_test.rb line 9 There is also another spot where we use /dev/null and it would need to be based on OS used. And last issue is related to spaces in paths/filenames as you've mentioned - that's a little messy.

mceachen commented 9 months ago

I'm the original author of this gem (I stopped using ruby more than a decade ago).

Kudos to @morozgrafix for keeping it alive! :muscle:

Windows filename support will at least require shenanigans like this: https://github.com/photostructure/exiftool-vendored.js/blob/main/src/FilenameCharsetArgs.ts

(I had to add a bunch of example filenames with different unicode block classes, and add windows to my GHA test matrix, and even then, there are issues with some multi-character emoji in filenames).