exiftool 1.2.7 → 1.3.1

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: 1745a40104081210f37e7c4a0a74c8d28bb96033d33422a7cd5313ddd5988a84
4
+ data.tar.gz: a3cb52d603d826c563053214d703423109bd27c53a55e2e0fee28d442b1a1a6f
5
5
  SHA512:
6
- metadata.gz: 98676eb8f202145076ce149a5c76dbf8cd1bd8ed0e145db9eb32cd103c3e70fec4df0e12255b6b477920213b0826b1773c54f3eb6c2e81619e9b96d3fe5ed6d3
7
- data.tar.gz: a103e0f0ba7926798f043fbb5b5ed7c35ad8d9f5669aa940835767027a68692c58db1ddeea3dff01e91c065af6e168c215470bc992e5a3d9cb80ca8ba9110dcc
6
+ metadata.gz: 0f39d3be529b9e6c2e3d5aef7ea4fce5a55ac3debe19532e6fc4310db5eacbb14b7738c71d2b7d60acc19f327f7901b66db4514571366676d985c3e2d363d542
7
+ data.tar.gz: c8d9fcaf46225552ed50340d1f91091e39fc699ba113fa51bd48e28de84c6b88727b958a74c5282dc7b4b601d4f6e0e7343cf2917147e30a7f22984ed4f9d5d1
@@ -48,7 +48,7 @@ class Exiftool
48
48
  private
49
49
 
50
50
  def lat_long?
51
- sym_key == :gps_latitude || sym_key == :gps_longitude
51
+ %i[gps_latitude gps_longitude].include?(sym_key)
52
52
  end
53
53
 
54
54
  def as_lat_long
@@ -21,7 +21,7 @@ class Exiftool
21
21
 
22
22
  civil_date = p.civil_date
23
23
  if civil_date
24
- civil_date_key = "#{p.sym_key}_civil".to_sym
24
+ civil_date_key = :"#{p.sym_key}_civil"
25
25
  @to_hash[civil_date_key] = civil_date
26
26
  end
27
27
  end
@@ -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.1')
5
5
  end
data/lib/exiftool.rb CHANGED
@@ -2,9 +2,11 @@
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'
9
+ require 'stringio'
8
10
 
9
11
  # Exiftool Class
10
12
  class Exiftool
@@ -30,7 +32,20 @@ class Exiftool
30
32
 
31
33
  # This is a string, not a float, to handle versions like "9.40" properly.
32
34
  def self.exiftool_version
33
- @exiftool_version ||= `#{command} -ver 2> /dev/null`.chomp
35
+ return @exiftool_version if defined?(@exiftool_version) && @exiftool_version
36
+
37
+ stdout_str = ''
38
+ begin
39
+ Open3.popen3(command, '-ver') do |_stdin, stdout, _stderr, wait_thr|
40
+ stdout_str = stdout.read.to_s.chomp
41
+ # Ensure the process is reaped
42
+ wait_thr.value
43
+ end
44
+ rescue Errno::ENOENT
45
+ stdout_str = ''
46
+ end
47
+
48
+ @exiftool_version = stdout_str
34
49
  end
35
50
 
36
51
  def self.expand_path(filename)
@@ -47,16 +62,40 @@ class Exiftool
47
62
 
48
63
  def initialize(filenames, exiftool_opts = '')
49
64
  @file2result = {}
65
+ io_input = nil
66
+ if filenames.is_a?(IO) || filenames.is_a?(StringIO)
67
+ io_input = filenames
68
+ filenames = ['-']
69
+ end
70
+
50
71
  filenames = [filenames] if filenames.is_a?(String) || filenames.is_a?(Pathname)
51
72
  return if filenames.empty?
52
73
 
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
74
+ expanded_filenames = filenames.map do |f|
75
+ f == '-' ? '-' : self.class.expand_path(f.to_s)
76
+ end
77
+ args = [
78
+ self.class.command,
79
+ *Shellwords.split(exiftool_opts),
80
+ '-j',
81
+ '-coordFormat', '%.8f',
82
+ *expanded_filenames
83
+ ]
84
+
85
+ json = ''
86
+ begin
87
+ Open3.popen3(*args) do |stdin, stdout, _stderr, wait_thr|
88
+ if io_input
89
+ IO.copy_stream(io_input, stdin)
90
+ stdin.close
91
+ end
92
+ json = stdout.read.to_s.chomp
93
+ wait_thr.value
94
+ end
95
+ rescue Errno::ENOENT
96
+ json = ''
97
+ end
98
+
60
99
  raise ExiftoolNotInstalled if json == ''
61
100
 
62
101
  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.1
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: []