mini_exiftool 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog +6 -0
- data/Tutorial +5 -3
- data/lib/mini_exiftool.rb +22 -5
- data/test/data/test_special_dates.jpg +0 -0
- data/test/test_special_dates.rb +52 -0
- metadata +50 -40
data/Changelog
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
Version 0.5.0
|
2
|
+
- New option :timestamps to create DateTime objects instead of Time objects
|
3
|
+
for timestamps (Fixing bug #16328)
|
4
|
+
- Invalid values of timestamps (i.e. 0000:00:00 00:00:00) are now mapped
|
5
|
+
to false
|
6
|
+
|
1
7
|
Version 0.4.1
|
2
8
|
- Compatibility for Ruby 1.9
|
3
9
|
|
data/Tutorial
CHANGED
@@ -54,7 +54,7 @@ the <code>:numerical</code> option to +true+ while generating a new
|
|
54
54
|
instance with new or using the <code>numerical=</code>-method
|
55
55
|
combining with calling <code>reload</code>.
|
56
56
|
|
57
|
-
Let's
|
57
|
+
Let's look at an example:
|
58
58
|
# standard: numerical is false
|
59
59
|
photo = MiniExiftool.new 'photo.jpg'
|
60
60
|
photo.exposure_time # => '1/60' (String)
|
@@ -66,13 +66,14 @@ This behaviour can be useful if you want to do calculations on the
|
|
66
66
|
value, if you only want to show the value the standard behaviour is
|
67
67
|
maybe better.
|
68
68
|
|
69
|
-
|
70
69
|
=== Further Example
|
71
70
|
|
72
71
|
For understanding reading access to meta data also have a look at the
|
73
72
|
example file <code>print_portraits.rb</code> in the +examples+
|
74
73
|
directory.
|
75
74
|
|
75
|
+
<b>TODO:</b> Describing the options <code>:composite</code> and
|
76
|
+
<code>:timestamps</code>!
|
76
77
|
|
77
78
|
== Lesson 2: Writing Meta Data
|
78
79
|
|
@@ -104,7 +105,8 @@ value of a specific tag is changed or a changing in general is
|
|
104
105
|
done. In the same way the +revert+-method reverts the value of a
|
105
106
|
specific tag or in general all changes.
|
106
107
|
|
108
|
+
You should also look at the rdoc information of MiniExiftool.
|
107
109
|
|
108
110
|
=== Further Example
|
109
111
|
|
110
|
-
See <code>shift_time.rb</code> in the +examples+ directory.
|
112
|
+
See <code>shift_time.rb</code> in the +examples+ directory.
|
data/lib/mini_exiftool.rb
CHANGED
@@ -25,19 +25,26 @@ class MiniExiftool
|
|
25
25
|
@@cmd = 'exiftool'
|
26
26
|
|
27
27
|
attr_reader :filename
|
28
|
-
attr_accessor :numerical, :composite, :errors
|
28
|
+
attr_accessor :numerical, :composite, :errors, :timestamps
|
29
29
|
|
30
|
-
VERSION = '0.
|
30
|
+
VERSION = '0.5.0'
|
31
31
|
|
32
|
-
# opts support at the moment
|
32
|
+
# +opts+ support at the moment
|
33
33
|
# * <code>:numerical</code> for numerical values, default is +false+
|
34
34
|
# * <code>:composite</code> for including composite tags while loading,
|
35
35
|
# default is +false+
|
36
|
+
# * <code>:timestamps</code> generating DateTime objects instead of
|
37
|
+
# Time objects if set to <code>DateTime</code>, default is +Time+
|
38
|
+
#
|
39
|
+
# <b>ATTENTION:</b> Time objects are created using <code>Time.local</code>
|
40
|
+
# therefore they use <em>your local timezone</em>, DateTime objects instead
|
41
|
+
# are created <em>without timezone</em>!
|
36
42
|
def initialize filename, opts={}
|
37
|
-
std_opts = {:numerical => false, :composite => false}
|
43
|
+
std_opts = {:numerical => false, :composite => false, :timestamps => Time}
|
38
44
|
opts = std_opts.update opts
|
39
45
|
@numerical = opts[:numerical]
|
40
46
|
@composite = opts[:composite]
|
47
|
+
@timestamps = opts[:timestamps]
|
41
48
|
@values = TagHash.new
|
42
49
|
@tag_names = TagHash.new
|
43
50
|
@changed_values = TagHash.new
|
@@ -244,7 +251,17 @@ class MiniExiftool
|
|
244
251
|
when /^\d{4}:\d\d:\d\d \d\d:\d\d:\d\d$/
|
245
252
|
arr = value.split /[: ]/
|
246
253
|
arr.map! {|elem| elem.to_i}
|
247
|
-
|
254
|
+
begin
|
255
|
+
if @timestamps == Time
|
256
|
+
value = Time.local *arr
|
257
|
+
elsif @timestamps == DateTime
|
258
|
+
value = DateTime.strptime(value,'%Y:%m:%d %H:%M:%S')
|
259
|
+
else
|
260
|
+
raise MiniExiftool::Error.new "Value #@timestamps not allowed for option timestamps."
|
261
|
+
end
|
262
|
+
rescue ArgumentError
|
263
|
+
value = false
|
264
|
+
end
|
248
265
|
when /^\d+\.\d+$/
|
249
266
|
value = value.to_f
|
250
267
|
when /^0+[1-9]+$/
|
Binary file
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'mini_exiftool'
|
4
|
+
require 'tempfile'
|
5
|
+
require 'test/unit'
|
6
|
+
begin
|
7
|
+
require 'turn'
|
8
|
+
rescue LoadError
|
9
|
+
end
|
10
|
+
|
11
|
+
class TestSpecialDates < Test::Unit::TestCase
|
12
|
+
|
13
|
+
def setup
|
14
|
+
data_dir = File.dirname(__FILE__) + '/data'
|
15
|
+
temp_file = Tempfile.new('test')
|
16
|
+
temp_file.close
|
17
|
+
@temp_filename = temp_file.path
|
18
|
+
org_filename = data_dir + '/test_special_dates.jpg'
|
19
|
+
FileUtils.cp org_filename, @temp_filename
|
20
|
+
@mini_exiftool = MiniExiftool.new @temp_filename
|
21
|
+
@mini_exiftool_datetime = MiniExiftool.new @temp_filename,
|
22
|
+
:timestamps => DateTime
|
23
|
+
end
|
24
|
+
|
25
|
+
# Catching bug [#16328] (1st part)
|
26
|
+
# Thanks to unknown
|
27
|
+
def test_datetime
|
28
|
+
datetime_original = @mini_exiftool.datetime_original
|
29
|
+
if datetime_original
|
30
|
+
assert_kind_of Time, datetime_original
|
31
|
+
else
|
32
|
+
assert_equal false, datetime_original
|
33
|
+
end
|
34
|
+
assert_kind_of DateTime, @mini_exiftool_datetime.datetime_original
|
35
|
+
assert_raise MiniExiftool::Error do
|
36
|
+
@mini_exiftool.timestamps = String
|
37
|
+
@mini_exiftool.reload
|
38
|
+
end
|
39
|
+
@mini_exiftool.timestamps = DateTime
|
40
|
+
@mini_exiftool.reload
|
41
|
+
assert_equal @mini_exiftool_datetime.datetime_original,
|
42
|
+
@mini_exiftool.datetime_original
|
43
|
+
end
|
44
|
+
|
45
|
+
# Catching bug [#16328] (2nd part)
|
46
|
+
# Thanks to Cecil Coupe
|
47
|
+
def test_invalid_date
|
48
|
+
assert_equal false, @mini_exiftool.modify_date
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
metadata
CHANGED
@@ -1,33 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.1
|
3
|
-
specification_version: 1
|
4
2
|
name: mini_exiftool
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2008-01-03 00:00:00 +01:00
|
8
|
-
summary: A library for nice OO access to the Exiftool command-line application written by Phil Harvey.
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: miniexiftool@googlemail.com
|
12
|
-
homepage: http://miniexiftool.rubyforge.org/
|
13
|
-
rubyforge_project: miniexiftool
|
14
|
-
description:
|
15
|
-
autorequire:
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: 0.5.0
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
7
|
- Jan Friedrich
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-02-01 00:00:00 +01:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: miniexiftool@googlemail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README
|
24
|
+
- Tutorial
|
31
25
|
files:
|
32
26
|
- lib/mini_exiftool.rb
|
33
27
|
- test/test_write.rb
|
@@ -37,6 +31,7 @@ files:
|
|
37
31
|
- test/test_save.rb
|
38
32
|
- test/test_composite.rb
|
39
33
|
- test/test_read_numerical.rb
|
34
|
+
- test/test_special_dates.rb
|
40
35
|
- examples/external_photo.rb
|
41
36
|
- examples/print_portraits.rb
|
42
37
|
- examples/shift_time.rb
|
@@ -47,8 +42,38 @@ files:
|
|
47
42
|
- test/data/test.jpg
|
48
43
|
- test/data/Canon.jpg
|
49
44
|
- test/data/INFORMATION
|
45
|
+
- test/data/test_special_dates.jpg
|
50
46
|
- README
|
51
47
|
- Tutorial
|
48
|
+
has_rdoc: true
|
49
|
+
homepage: http://miniexiftool.rubyforge.org/
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options:
|
52
|
+
- --title
|
53
|
+
- MiniExiftool API documentation
|
54
|
+
- --main
|
55
|
+
- README
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: "0"
|
63
|
+
version:
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
69
|
+
version:
|
70
|
+
requirements: []
|
71
|
+
|
72
|
+
rubyforge_project: miniexiftool
|
73
|
+
rubygems_version: 1.0.1
|
74
|
+
signing_key:
|
75
|
+
specification_version: 2
|
76
|
+
summary: A library for nice OO access to the Exiftool command-line application written by Phil Harvey.
|
52
77
|
test_files:
|
53
78
|
- test/test_write.rb
|
54
79
|
- test/test_read.rb
|
@@ -57,19 +82,4 @@ test_files:
|
|
57
82
|
- test/test_save.rb
|
58
83
|
- test/test_composite.rb
|
59
84
|
- test/test_read_numerical.rb
|
60
|
-
|
61
|
-
- --title
|
62
|
-
- MiniExiftool API documentation
|
63
|
-
- --main
|
64
|
-
- README
|
65
|
-
extra_rdoc_files:
|
66
|
-
- README
|
67
|
-
- Tutorial
|
68
|
-
executables: []
|
69
|
-
|
70
|
-
extensions: []
|
71
|
-
|
72
|
-
requirements: []
|
73
|
-
|
74
|
-
dependencies: []
|
75
|
-
|
85
|
+
- test/test_special_dates.rb
|