exiftool 1.2.7 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b8b9a77c5be9b18ddea87db631f35aa637e9da7925c74ac13aee5eee4fcf56b0
4
- data.tar.gz: 2f07ab5933c0488aa8c665e841cd0ff39e24442af61e987970dfdddf637ac83f
3
+ metadata.gz: 0cce583d1e852f12a30ce3e82af8e146608d96b6453829c2bef67b44605ada4e
4
+ data.tar.gz: 2769a2ad8fb58fb1e7882491aba98a4ab7035fbf10a68fb727c3eac98ea76a9a
5
5
  SHA512:
6
- metadata.gz: 98676eb8f202145076ce149a5c76dbf8cd1bd8ed0e145db9eb32cd103c3e70fec4df0e12255b6b477920213b0826b1773c54f3eb6c2e81619e9b96d3fe5ed6d3
7
- data.tar.gz: a103e0f0ba7926798f043fbb5b5ed7c35ad8d9f5669aa940835767027a68692c58db1ddeea3dff01e91c065af6e168c215470bc992e5a3d9cb80ca8ba9110dcc
6
+ metadata.gz: 00f23a8d0168120ea30af758f58391845f8b7019239a6310f4a63652b8ec32baada0e21bc69bc50761575206208c6c0b43faec565a73f0a8641dc6d85ac91b1c
7
+ data.tar.gz: 32efaa4bb7ca675822858c9147f4d0a430c6efb1a7a58d24d1cd601d1d08dfc618a053ded041ba59fcb830973252f8e8ae9e5d9cc085dd1f875dade49fc40b09
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Exiftool
4
- VERSION = Gem::Version.new('1.2.7')
4
+ VERSION = Gem::Version.new('1.3.0')
5
5
  end
data/lib/exiftool.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'json'
4
4
  require 'shellwords'
5
+ require 'open3'
5
6
  require 'exiftool/result'
6
7
  require 'forwardable'
7
8
  require 'pathname'
@@ -30,7 +31,20 @@ class Exiftool
30
31
 
31
32
  # This is a string, not a float, to handle versions like "9.40" properly.
32
33
  def self.exiftool_version
33
- @exiftool_version ||= `#{command} -ver 2> /dev/null`.chomp
34
+ return @exiftool_version if defined?(@exiftool_version) && @exiftool_version
35
+
36
+ stdout_str = ''
37
+ begin
38
+ Open3.popen3(command, '-ver') do |_stdin, stdout, _stderr, wait_thr|
39
+ stdout_str = stdout.read.to_s.chomp
40
+ # Ensure the process is reaped
41
+ wait_thr.value
42
+ end
43
+ rescue Errno::ENOENT
44
+ stdout_str = ''
45
+ end
46
+
47
+ @exiftool_version = stdout_str
34
48
  end
35
49
 
36
50
  def self.expand_path(filename)
@@ -47,16 +61,40 @@ class Exiftool
47
61
 
48
62
  def initialize(filenames, exiftool_opts = '')
49
63
  @file2result = {}
64
+ io_input = nil
65
+ if filenames.is_a?(IO)
66
+ io_input = filenames
67
+ filenames = ['-']
68
+ end
69
+
50
70
  filenames = [filenames] if filenames.is_a?(String) || filenames.is_a?(Pathname)
51
71
  return if filenames.empty?
52
72
 
53
- escaped_filenames = filenames.map do |f|
54
- Shellwords.escape(self.class.expand_path(f.to_s))
55
- end.join(' ')
56
- # I'd like to use -dateformat, but it doesn't support timezone offsets properly,
57
- # nor sub-second timestamps.
58
- cmd = "#{self.class.command} #{exiftool_opts} -j -coordFormat \"%.8f\" #{escaped_filenames} 2> /dev/null"
59
- json = `#{cmd}`.chomp
73
+ expanded_filenames = filenames.map do |f|
74
+ f == '-' ? '-' : self.class.expand_path(f.to_s)
75
+ end
76
+ args = [
77
+ self.class.command,
78
+ *Shellwords.split(exiftool_opts),
79
+ '-j',
80
+ '-coordFormat', '%.8f',
81
+ *expanded_filenames
82
+ ]
83
+
84
+ json = ''
85
+ begin
86
+ Open3.popen3(*args) do |stdin, stdout, _stderr, wait_thr|
87
+ if io_input
88
+ IO.copy_stream(io_input, stdin)
89
+ stdin.close
90
+ end
91
+ json = stdout.read.to_s.chomp
92
+ wait_thr.value
93
+ end
94
+ rescue Errno::ENOENT
95
+ json = ''
96
+ end
97
+
60
98
  raise ExiftoolNotInstalled if json == ''
61
99
 
62
100
  JSON.parse(json).each do |raw|
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exiftool
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.7
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew McEachen
8
8
  - Sergey Morozov
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2025-09-03 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: json
@@ -42,7 +41,6 @@ licenses:
42
41
  - MIT
43
42
  metadata:
44
43
  rubygems_mfa_required: 'true'
45
- post_install_message:
46
44
  rdoc_options: []
47
45
  require_paths:
48
46
  - lib
@@ -58,8 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
56
  version: '0'
59
57
  requirements:
60
58
  - ExifTool (see http://exiftool.org)
61
- rubygems_version: 3.3.3
62
- signing_key:
59
+ rubygems_version: 3.6.9
63
60
  specification_version: 4
64
61
  summary: Multiget ExifTool wrapper for ruby
65
62
  test_files: []