mini_exiftool 1.4.4 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/Changelog CHANGED
@@ -1,3 +1,9 @@
1
+ v1.5.0
2
+ - Supporting exiftool command-line option -m.
3
+ rubyforge request [#29587]
4
+ Thanks to Michael Grove for reporting.
5
+ - Supporting rational values.
6
+
1
7
  v1.4.4
2
8
  - Fix escaping of values for older versions of Shellwords.
3
9
 
@@ -27,19 +27,21 @@ class MiniExiftool
27
27
  @@cmd = 'exiftool'
28
28
 
29
29
  # Hash of the standard options used when call MiniExiftool.new
30
- @@opts = { :numerical => false, :composite => true, :convert_encoding => false, :timestamps => Time }
30
+ @@opts = { :numerical => false, :composite => true, :convert_encoding => false, :ignore_minor_errors => false, :timestamps => Time }
31
31
 
32
32
  attr_reader :filename
33
- attr_accessor :numerical, :composite, :convert_encoding, :errors, :timestamps
33
+ attr_accessor :numerical, :composite, :convert_encoding, :ignore_minor_errors, :errors, :timestamps
34
34
 
35
- VERSION = '1.4.4'
35
+ VERSION = '1.5.0'
36
36
 
37
37
  # +opts+ support at the moment
38
38
  # * <code>:numerical</code> for numerical values, default is +false+
39
39
  # * <code>:composite</code> for including composite tags while loading,
40
40
  # default is +true+
41
41
  # * <code>:convert_encoding</code> convert encoding (See -L-option of
42
- # the exiftool command-line application, default is +false+
42
+ # the exiftool command-line application, default is +false+)
43
+ # * <code>:ignore_minor_errors</code> ignore minor errors (See -m-option
44
+ # of the exiftool command-line application, default is +false+)
43
45
  # * <code>:timestamps</code> generating DateTime objects instead of
44
46
  # Time objects if set to <code>DateTime</code>, default is +Time+
45
47
  #
@@ -51,6 +53,7 @@ class MiniExiftool
51
53
  @numerical = opts[:numerical]
52
54
  @composite = opts[:composite]
53
55
  @convert_encoding = opts[:convert_encoding]
56
+ @ignore_minor_errors = opts[:ignore_minor_errors]
54
57
  @timestamps = opts[:timestamps]
55
58
  @values = TagHash.new
56
59
  @tag_names = TagHash.new
@@ -159,6 +162,7 @@ class MiniExiftool
159
162
  opt_params = ''
160
163
  opt_params << (arr_val.detect {|x| x.kind_of?(Numeric)} ? '-n ' : '')
161
164
  opt_params << (@convert_encoding ? '-L ' : '')
165
+ opt_params << (@ignore_minor_errors ? '-m' : '')
162
166
  cmd = %Q(#@@cmd -q -P -overwrite_original #{opt_params} #{tag_params} #{temp_filename})
163
167
  if convert_encoding && cmd.respond_to?(:encode)
164
168
  cmd.encode('ISO-8859-1')
@@ -341,6 +345,8 @@ class MiniExiftool
341
345
  # nothing => String
342
346
  when /^-?\d+$/
343
347
  value = value.to_i
348
+ when %r(^\d+/\d+$)
349
+ value = Rational(value)
344
350
  when /^[\d ]+$/
345
351
  # nothing => String
346
352
  when /#{@@separator}/
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "mini_exiftool"
5
- s.version = "1.4.4"
5
+ s.version = "1.5.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Jan Friedrich"]
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.description = "This library is wrapper for the Exiftool command-line application (http://www.sno.phy.queensu.ca/~phil/exiftool)."
11
11
  s.email = "janfri26@gmail.com"
12
12
  s.extra_rdoc_files = ["README.rdoc", "Tutorial.rdoc", "lib/mini_exiftool.rb"]
13
- s.files = ["COPYING", "Changelog", "Manifest", "README.rdoc", "Rakefile", "TODO", "Tutorial.rdoc", ".yardopts", "examples/external_photo.rb", "examples/print_portraits.rb", "examples/shift_time.rb", "lib/mini_exiftool.rb", "setup.rb", "test/data/Canon.jpg", "test/data/INFORMATION", "test/data/test.jpg", "test/data/test_special_dates.jpg", "test/helpers_for_test.rb", "test/test_class_methods.rb", "test/test_composite.rb", "test/test_dumping.rb", "test/test_read.rb", "test/test_read_numerical.rb", "test/test_save.rb", "test/test_special.rb", "test/test_special_dates.rb", "test/test_write.rb", "mini_exiftool.gemspec"]
13
+ s.files = ["COPYING", "Changelog", "Manifest", "README.rdoc", "Rakefile", "TODO", "Tutorial.rdoc", ".yardopts", "examples/external_photo.rb", "examples/print_portraits.rb", "examples/shift_time.rb", "lib/mini_exiftool.rb", "setup.rb", "test/data/Canon.jpg", "test/data/INFORMATION", "test/data/test.jpg", "test/data/test_special_dates.jpg", "test/helpers_for_test.rb", "test/test_class_methods.rb", "test/test_composite.rb", "test/test_dumping.rb", "test/test_read.rb", "test/test_read_numerical.rb", "test/test_save.rb", "test/test_special.rb", "test/test_special_dates.rb", "test/test_write.rb", "mini_exiftool.gemspec", "test/test_bad_preview_ifd.rb"]
14
14
  s.homepage = "http://gitorious.org/mini_exiftool"
15
15
  s.post_install_message = "\n+-----------------------------------------------------------------------+\n| Please ensure you have installed exiftool and it's found in your PATH |\n| (Try \"exiftool -ver\" on your commandline). For more details see |\n| http://www.sno.phy.queensu.ca/~phil/exiftool/install.html |\n+-----------------------------------------------------------------------+\n "
16
16
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Mini_exiftool", "--main", "README.rdoc"]
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.rubyforge_project = "mini_exiftool"
19
19
  s.rubygems_version = "1.8.24"
20
20
  s.summary = "This library is wrapper for the Exiftool command-line application (http://www.sno.phy.queensu.ca/~phil/exiftool)."
21
- s.test_files = ["test/helpers_for_test.rb", "test/test_class_methods.rb", "test/test_composite.rb", "test/test_dumping.rb", "test/test_read.rb", "test/test_read_numerical.rb", "test/test_save.rb", "test/test_special.rb", "test/test_special_dates.rb", "test/test_write.rb"]
21
+ s.test_files = ["test/helpers_for_test.rb", "test/test_bad_preview_ifd.rb", "test/test_class_methods.rb", "test/test_composite.rb", "test/test_dumping.rb", "test/test_read.rb", "test/test_read_numerical.rb", "test/test_save.rb", "test/test_special.rb", "test/test_special_dates.rb", "test/test_write.rb"]
22
22
 
23
23
  if s.respond_to? :specification_version then
24
24
  s.specification_version = 3
@@ -0,0 +1,29 @@
1
+ # -- encoding: utf-8 --
2
+ require 'helpers_for_test'
3
+
4
+ class TestBadPreviewIFD < TestCase
5
+
6
+ include TempfileTest
7
+
8
+ def setup
9
+ super
10
+ @org_filename = @data_dir + '/Bad_PreviewIFD.jpg'
11
+ FileUtils.cp @org_filename, @temp_filename
12
+ @bad_preview_ifd = MiniExiftool.new @temp_filename
13
+ end
14
+
15
+ # Feature request rubyforge [#29587]
16
+ # Thanks to Michael Grove for reporting
17
+ def test_m_option
18
+ title = 'anything'
19
+ @bad_preview_ifd.title = title
20
+ assert_equal false, @bad_preview_ifd.save, '-m option seems to be not neccessary'
21
+ @bad_preview_ifd.reload
22
+ @bad_preview_ifd.title = title
23
+ @bad_preview_ifd.ignore_minor_errors = true
24
+ assert_equal true, @bad_preview_ifd.save, 'Error while saving'
25
+ @bad_preview_ifd.reload
26
+ assert_equal title, @bad_preview_ifd.title
27
+ end
28
+
29
+ end
@@ -31,6 +31,7 @@ class TestRead < TestCase
31
31
  assert_kind_of String, (@mini_exiftool['SubjectLocation'] || @mini_exiftool['SubjectArea'])
32
32
  assert_kind_of Array, @mini_exiftool['Keywords']
33
33
  assert_kind_of String, @mini_exiftool['SupplementalCategories']
34
+ assert_kind_of Rational, @mini_exiftool.shutterspeed
34
35
  end
35
36
 
36
37
  def test_list_tags
@@ -90,7 +90,7 @@ class TestWrite < TestCase
90
90
 
91
91
  def test_float_conversion
92
92
  assert_kind_of Float, @mini_exiftool_num['BrightnessValue']
93
- new_time = @mini_exiftool_num['BrightnessValue'] + 1
93
+ new_time = @mini_exiftool_num['BrightnessValue'] + 1
94
94
  @mini_exiftool_num['BrightnessValue'] = new_time
95
95
  assert_equal new_time, @mini_exiftool_num['BrightnessValue']
96
96
  assert_equal true, @mini_exiftool_num.changed_tags.include?('BrightnessValue')
@@ -109,6 +109,16 @@ class TestWrite < TestCase
109
109
  assert_equal new_mode, @mini_exiftool_num['MeteringMode']
110
110
  end
111
111
 
112
+ def test_rational_conversion
113
+ new_exposure_time = Rational(1, 125)
114
+ @mini_exiftool.exposure_time = new_exposure_time
115
+ assert @mini_exiftool.changed?, 'No changing of value.'
116
+ ok = @mini_exiftool.save
117
+ assert ok, 'Saving failed.'
118
+ @mini_exiftool.reload
119
+ assert_equal new_exposure_time, @mini_exiftool.exposure_time
120
+ end
121
+
112
122
  def test_list_conversion
113
123
  arr = ['a', 'b', 'c']
114
124
  @mini_exiftool['Keywords'] = arr
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: mini_exiftool
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.4.4
5
+ version: 1.5.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jan Friedrich
@@ -52,6 +52,7 @@ files:
52
52
  - test/test_special_dates.rb
53
53
  - test/test_write.rb
54
54
  - mini_exiftool.gemspec
55
+ - test/test_bad_preview_ifd.rb
55
56
  homepage: http://gitorious.org/mini_exiftool
56
57
  licenses: []
57
58
 
@@ -91,6 +92,7 @@ specification_version: 3
91
92
  summary: This library is wrapper for the Exiftool command-line application (http://www.sno.phy.queensu.ca/~phil/exiftool).
92
93
  test_files:
93
94
  - test/helpers_for_test.rb
95
+ - test/test_bad_preview_ifd.rb
94
96
  - test/test_class_methods.rb
95
97
  - test/test_composite.rb
96
98
  - test/test_dumping.rb