multi_exiftool 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/CHANGELOG +1 -1
  2. data/LICENSE +21 -0
  3. data/Manifest +16 -23
  4. data/README +77 -16
  5. data/Rakefile +17 -38
  6. data/examples/01_simple_reading.rb +13 -0
  7. data/examples/02_simple_writing.rb +19 -0
  8. data/examples/03_reading_using_groups.rb +28 -0
  9. data/lib/multi_exiftool.rb +6 -38
  10. data/lib/multi_exiftool/executable.rb +67 -0
  11. data/lib/multi_exiftool/reader.rb +60 -0
  12. data/lib/multi_exiftool/values.rb +60 -0
  13. data/lib/multi_exiftool/writer.rb +55 -0
  14. data/multi_exiftool.gemspec +25 -16
  15. data/test/helper.rb +27 -0
  16. data/test/test_reader.rb +135 -0
  17. data/test/test_values.rb +75 -0
  18. data/test/test_values_using_groups.rb +61 -0
  19. data/test/test_writer.rb +102 -0
  20. metadata +49 -47
  21. data/COPYING +0 -165
  22. data/data/fixtures/read_non_existing_file.stderr +0 -1
  23. data/data/fixtures/read_non_existing_file.stdout +0 -0
  24. data/data/fixtures/read_one_file.stderr +0 -0
  25. data/data/fixtures/read_one_file.stdout +0 -92
  26. data/data/fixtures/read_two_files.stderr +0 -0
  27. data/data/fixtures/read_two_files.stdout +0 -212
  28. data/data/regression/read_command.rb +0 -12
  29. data/data/regression/read_command.rb.out +0 -16
  30. data/data/regression/write_command.rb +0 -16
  31. data/data/regression/write_command.rb.out +0 -40
  32. data/lib/multi_exiftool/command_generator.rb +0 -68
  33. data/lib/multi_exiftool/parser.rb +0 -43
  34. data/lib/multi_exiftool/read_object.rb +0 -57
  35. data/script/colorize.rb +0 -6
  36. data/script/generate_fixture.rb +0 -27
  37. data/test/test_command_generator.rb +0 -89
  38. data/test/test_helper.rb +0 -44
  39. data/test/test_parser.rb +0 -51
  40. data/test/test_read_object.rb +0 -36
@@ -0,0 +1,102 @@
1
+ # coding: utf-8
2
+ require_relative 'helper'
3
+
4
+ class TestWriter < Test::Unit::TestCase
5
+
6
+ setup do
7
+ @writer = MultiExiftool::Writer.new
8
+ end
9
+
10
+ context 'command method' do
11
+
12
+ test 'simple case' do
13
+ @writer.filenames = %w(a.jpg b.tif c.bmp)
14
+ @writer.values = {:author => 'janfri'}
15
+ command = 'exiftool -author=janfri a.jpg b.tif c.bmp'
16
+ assert_equal command, @writer.command
17
+ end
18
+
19
+ test 'no filenames set' do
20
+ @writer.values = {:author => 'janfri'}
21
+ assert_raises MultiExiftool::Error do
22
+ @writer.command
23
+ end
24
+ @writer.filenames = []
25
+ assert_raises MultiExiftool::Error do
26
+ @writer.command
27
+ end
28
+ end
29
+
30
+ test 'no values set' do
31
+ @writer.filenames = %w(a.jpg b.tif c.bmp)
32
+ assert_raises MultiExiftool::Error do
33
+ @writer.command
34
+ end
35
+ @writer.values = []
36
+ assert_raises MultiExiftool::Error do
37
+ @writer.command
38
+ end
39
+ end
40
+
41
+ test 'tags with spaces in values' do
42
+ @writer.filenames = %w(a.jpg b.tif c.bmp)
43
+ @writer.values = {:author => 'janfri', :comment => 'some comment'}
44
+ command = 'exiftool -author=janfri -comment=some\ comment a.jpg b.tif c.bmp'
45
+ assert_equal command, @writer.command
46
+ end
47
+
48
+ test 'filenames with spaces' do
49
+ @writer.filenames = ['one file with spaces.jpg', 'another file with spaces.tif']
50
+ @writer.values = {:author => 'janfri'}
51
+ command = 'exiftool -author=janfri one\ file\ with\ spaces.jpg another\ file\ with\ spaces.tif'
52
+ assert_equal command, @writer.command
53
+ end
54
+
55
+ test 'options with boolean argument' do
56
+ @writer.filenames = %w(a.jpg b.tif c.bmp)
57
+ @writer.values = {:author => 'janfri'}
58
+ @writer.options = {:overwrite_original => true}
59
+ command = 'exiftool -overwrite_original -author=janfri a.jpg b.tif c.bmp'
60
+ assert_equal command, @writer.command
61
+ end
62
+
63
+ test 'options with value argument' do
64
+ @writer.filenames = %w(a.jpg b.tif c.bmp)
65
+ @writer.values = {:author => 'janfri'}
66
+ @writer.options = {:out => 'output_file'}
67
+ command = 'exiftool -out output_file -author=janfri a.jpg b.tif c.bmp'
68
+ assert_equal command, @writer.command
69
+ end
70
+
71
+ test 'numerical flag' do
72
+ @writer.filenames = %w(a.jpg b.tif c.bmp)
73
+ @writer.values = {:author => 'janfri'}
74
+ @writer.numerical = true
75
+ command = 'exiftool -n -author=janfri a.jpg b.tif c.bmp'
76
+ assert_equal command, @writer.command
77
+ end
78
+
79
+ test 'overwrite_original flag' do
80
+ @writer.filenames = %w(a.jpg b.tif c.bmp)
81
+ @writer.values = {author: 'janfri'}
82
+ @writer.overwrite_original = true
83
+ command = 'exiftool -overwrite_original -author=janfri a.jpg b.tif c.bmp'
84
+ assert_equal command, @writer.command
85
+ end
86
+
87
+ end
88
+
89
+ context 'write method' do
90
+
91
+ test 'succsessfull write' do
92
+ mocking_open3('exiftool -author=janfri a.jpg b.tif c.bmp', '', '')
93
+ @writer.filenames = %w(a.jpg b.tif c.bmp)
94
+ @writer.values = {:author => 'janfri'}
95
+ rc = @writer.write
96
+ assert_equal [], @writer.errors
97
+ assert_equal true, rc
98
+ end
99
+
100
+ end
101
+
102
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multi_exiftool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Friedrich
@@ -9,11 +9,11 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-11-25 00:00:00 +01:00
12
+ date: 2010-01-27 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: yact
16
+ name: contest
17
17
  type: :development
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
@@ -22,50 +22,52 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: "0"
24
24
  version:
25
- description: ""
26
- email: janfri.rubyforge@gmail.com
25
+ description: This library is wrapper for the Exiftool command-line application (http://www.sno.phy.queensu.ca/~phil/exiftool) written by Phil Harvey. It is designed for dealing with multiple files at once by creating commands to call exiftool with various arguments, call it and parsing the results.
26
+ email: janfri26@gmail.com
27
27
  executables: []
28
28
 
29
29
  extensions: []
30
30
 
31
31
  extra_rdoc_files:
32
- - lib/multi_exiftool.rb
33
- - lib/multi_exiftool/parser.rb
34
- - lib/multi_exiftool/command_generator.rb
35
- - lib/multi_exiftool/read_object.rb
36
- - README
37
32
  - CHANGELOG
38
- - COPYING
33
+ - LICENSE
34
+ - README
35
+ - lib/multi_exiftool.rb
36
+ - lib/multi_exiftool/executable.rb
37
+ - lib/multi_exiftool/reader.rb
38
+ - lib/multi_exiftool/values.rb
39
+ - lib/multi_exiftool/writer.rb
39
40
  files:
40
- - Rakefile
41
+ - CHANGELOG
42
+ - LICENSE
41
43
  - Manifest
42
- - test/test_command_generator.rb
43
- - test/test_helper.rb
44
- - test/test_parser.rb
45
- - test/test_read_object.rb
46
- - lib/multi_exiftool.rb
47
- - lib/multi_exiftool/parser.rb
48
- - lib/multi_exiftool/command_generator.rb
49
- - lib/multi_exiftool/read_object.rb
50
44
  - README
51
- - data/fixtures/read_non_existing_file.stderr
52
- - data/fixtures/read_non_existing_file.stdout
53
- - data/fixtures/read_two_files.stderr
54
- - data/fixtures/read_one_file.stderr
55
- - data/fixtures/read_one_file.stdout
56
- - data/fixtures/read_two_files.stdout
57
- - data/regression/read_command.rb
58
- - data/regression/read_command.rb.out
59
- - data/regression/write_command.rb
60
- - data/regression/write_command.rb.out
61
- - script/generate_fixture.rb
62
- - script/colorize.rb
63
- - CHANGELOG
64
- - COPYING
45
+ - Rakefile
46
+ - examples/01_simple_reading.rb
47
+ - examples/02_simple_writing.rb
48
+ - examples/03_reading_using_groups.rb
49
+ - lib/multi_exiftool.rb
50
+ - lib/multi_exiftool/executable.rb
51
+ - lib/multi_exiftool/reader.rb
52
+ - lib/multi_exiftool/values.rb
53
+ - lib/multi_exiftool/writer.rb
54
+ - test/helper.rb
55
+ - test/test_reader.rb
56
+ - test/test_values.rb
57
+ - test/test_values_using_groups.rb
58
+ - test/test_writer.rb
65
59
  - multi_exiftool.gemspec
66
60
  has_rdoc: true
67
- homepage: http://multiexiftool.rubyforge.org
68
- post_install_message:
61
+ homepage: http://rubyforge.org/projects/multiexiftool
62
+ licenses: []
63
+
64
+ post_install_message: "\n\
65
+ +-----------------------------------------------------------------------+\n\
66
+ | Please ensure you have installed exiftool version 7.65 or higher and |\n\
67
+ | it's found in your PATH (Try \"exiftool -ver\" on your commandline). |\n\
68
+ | For more details see |\n\
69
+ | http://www.sno.phy.queensu.ca/~phil/exiftool/install.html |\n\
70
+ +-----------------------------------------------------------------------+\n "
69
71
  rdoc_options:
70
72
  - --line-numbers
71
73
  - --inline-source
@@ -79,7 +81,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
79
81
  requirements:
80
82
  - - ">="
81
83
  - !ruby/object:Gem::Version
82
- version: "0"
84
+ version: 1.9.1
83
85
  version:
84
86
  required_rubygems_version: !ruby/object:Gem::Requirement
85
87
  requirements:
@@ -87,15 +89,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
89
  - !ruby/object:Gem::Version
88
90
  version: "1.2"
89
91
  version:
90
- requirements: []
91
-
92
- rubyforge_project: multiexiftool
93
- rubygems_version: 1.3.1
92
+ requirements:
93
+ - exiftool, version 7.65 or higher
94
+ rubyforge_project: multi_exiftool
95
+ rubygems_version: 1.3.5
94
96
  signing_key:
95
- specification_version: 2
96
- summary: ""
97
+ specification_version: 3
98
+ summary: This library is wrapper for the Exiftool command-line application (http://www.sno.phy.queensu.ca/~phil/exiftool).
97
99
  test_files:
98
- - test/test_read_object.rb
99
- - test/test_helper.rb
100
- - test/test_command_generator.rb
101
- - test/test_parser.rb
100
+ - test/test_reader.rb
101
+ - test/test_values.rb
102
+ - test/test_values_using_groups.rb
103
+ - test/test_writer.rb
data/COPYING DELETED
@@ -1,165 +0,0 @@
1
- GNU LESSER GENERAL PUBLIC LICENSE
2
- Version 3, 29 June 2007
3
-
4
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
- Everyone is permitted to copy and distribute verbatim copies
6
- of this license document, but changing it is not allowed.
7
-
8
-
9
- This version of the GNU Lesser General Public License incorporates
10
- the terms and conditions of version 3 of the GNU General Public
11
- License, supplemented by the additional permissions listed below.
12
-
13
- 0. Additional Definitions.
14
-
15
- As used herein, "this License" refers to version 3 of the GNU Lesser
16
- General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
- General Public License.
18
-
19
- "The Library" refers to a covered work governed by this License,
20
- other than an Application or a Combined Work as defined below.
21
-
22
- An "Application" is any work that makes use of an interface provided
23
- by the Library, but which is not otherwise based on the Library.
24
- Defining a subclass of a class defined by the Library is deemed a mode
25
- of using an interface provided by the Library.
26
-
27
- A "Combined Work" is a work produced by combining or linking an
28
- Application with the Library. The particular version of the Library
29
- with which the Combined Work was made is also called the "Linked
30
- Version".
31
-
32
- The "Minimal Corresponding Source" for a Combined Work means the
33
- Corresponding Source for the Combined Work, excluding any source code
34
- for portions of the Combined Work that, considered in isolation, are
35
- based on the Application, and not on the Linked Version.
36
-
37
- The "Corresponding Application Code" for a Combined Work means the
38
- object code and/or source code for the Application, including any data
39
- and utility programs needed for reproducing the Combined Work from the
40
- Application, but excluding the System Libraries of the Combined Work.
41
-
42
- 1. Exception to Section 3 of the GNU GPL.
43
-
44
- You may convey a covered work under sections 3 and 4 of this License
45
- without being bound by section 3 of the GNU GPL.
46
-
47
- 2. Conveying Modified Versions.
48
-
49
- If you modify a copy of the Library, and, in your modifications, a
50
- facility refers to a function or data to be supplied by an Application
51
- that uses the facility (other than as an argument passed when the
52
- facility is invoked), then you may convey a copy of the modified
53
- version:
54
-
55
- a) under this License, provided that you make a good faith effort to
56
- ensure that, in the event an Application does not supply the
57
- function or data, the facility still operates, and performs
58
- whatever part of its purpose remains meaningful, or
59
-
60
- b) under the GNU GPL, with none of the additional permissions of
61
- this License applicable to that copy.
62
-
63
- 3. Object Code Incorporating Material from Library Header Files.
64
-
65
- The object code form of an Application may incorporate material from
66
- a header file that is part of the Library. You may convey such object
67
- code under terms of your choice, provided that, if the incorporated
68
- material is not limited to numerical parameters, data structure
69
- layouts and accessors, or small macros, inline functions and templates
70
- (ten or fewer lines in length), you do both of the following:
71
-
72
- a) Give prominent notice with each copy of the object code that the
73
- Library is used in it and that the Library and its use are
74
- covered by this License.
75
-
76
- b) Accompany the object code with a copy of the GNU GPL and this license
77
- document.
78
-
79
- 4. Combined Works.
80
-
81
- You may convey a Combined Work under terms of your choice that,
82
- taken together, effectively do not restrict modification of the
83
- portions of the Library contained in the Combined Work and reverse
84
- engineering for debugging such modifications, if you also do each of
85
- the following:
86
-
87
- a) Give prominent notice with each copy of the Combined Work that
88
- the Library is used in it and that the Library and its use are
89
- covered by this License.
90
-
91
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
- document.
93
-
94
- c) For a Combined Work that displays copyright notices during
95
- execution, include the copyright notice for the Library among
96
- these notices, as well as a reference directing the user to the
97
- copies of the GNU GPL and this license document.
98
-
99
- d) Do one of the following:
100
-
101
- 0) Convey the Minimal Corresponding Source under the terms of this
102
- License, and the Corresponding Application Code in a form
103
- suitable for, and under terms that permit, the user to
104
- recombine or relink the Application with a modified version of
105
- the Linked Version to produce a modified Combined Work, in the
106
- manner specified by section 6 of the GNU GPL for conveying
107
- Corresponding Source.
108
-
109
- 1) Use a suitable shared library mechanism for linking with the
110
- Library. A suitable mechanism is one that (a) uses at run time
111
- a copy of the Library already present on the user's computer
112
- system, and (b) will operate properly with a modified version
113
- of the Library that is interface-compatible with the Linked
114
- Version.
115
-
116
- e) Provide Installation Information, but only if you would otherwise
117
- be required to provide such information under section 6 of the
118
- GNU GPL, and only to the extent that such information is
119
- necessary to install and execute a modified version of the
120
- Combined Work produced by recombining or relinking the
121
- Application with a modified version of the Linked Version. (If
122
- you use option 4d0, the Installation Information must accompany
123
- the Minimal Corresponding Source and Corresponding Application
124
- Code. If you use option 4d1, you must provide the Installation
125
- Information in the manner specified by section 6 of the GNU GPL
126
- for conveying Corresponding Source.)
127
-
128
- 5. Combined Libraries.
129
-
130
- You may place library facilities that are a work based on the
131
- Library side by side in a single library together with other library
132
- facilities that are not Applications and are not covered by this
133
- License, and convey such a combined library under terms of your
134
- choice, if you do both of the following:
135
-
136
- a) Accompany the combined library with a copy of the same work based
137
- on the Library, uncombined with any other library facilities,
138
- conveyed under the terms of this License.
139
-
140
- b) Give prominent notice with the combined library that part of it
141
- is a work based on the Library, and explaining where to find the
142
- accompanying uncombined form of the same work.
143
-
144
- 6. Revised Versions of the GNU Lesser General Public License.
145
-
146
- The Free Software Foundation may publish revised and/or new versions
147
- of the GNU Lesser General Public License from time to time. Such new
148
- versions will be similar in spirit to the present version, but may
149
- differ in detail to address new problems or concerns.
150
-
151
- Each version is given a distinguishing version number. If the
152
- Library as you received it specifies that a certain numbered version
153
- of the GNU Lesser General Public License "or any later version"
154
- applies to it, you have the option of following the terms and
155
- conditions either of that published version or of any later version
156
- published by the Free Software Foundation. If the Library as you
157
- received it does not specify a version number of the GNU Lesser
158
- General Public License, you may choose any version of the GNU Lesser
159
- General Public License ever published by the Free Software Foundation.
160
-
161
- If the Library as you received it specifies that a proxy can decide
162
- whether future versions of the GNU Lesser General Public License shall
163
- apply, that proxy's public statement of acceptance of any version is
164
- permanent authorization for you to choose that version for the
165
- Library.
@@ -1 +0,0 @@
1
- File not found: non_existing_file
File without changes
@@ -1,92 +0,0 @@
1
- ExifToolVersion 7.03
2
- FileName sea.jpg
3
- Directory /home/janfri
4
- FileSize 3 MB
5
- FileModifyDate 2008:05:21 20:59:44
6
- FileType JPEG
7
- MIMEType image/jpeg
8
- ExifByteOrder Big-endian (Motorola)
9
- ImageDescription KONICA MINOLTA DIGITAL CAMERA
10
- Make KONICA MINOLTA
11
- Model DYNAX 7D
12
- Orientation Horizontal (normal)
13
- XResolution 72
14
- YResolution 72
15
- ResolutionUnit inches
16
- Software DYNAX 7D v1.10
17
- ModifyDate 2005:10:06 15:41:08
18
- YCbCrPositioning Centered
19
- ExposureTime 1/200
20
- FNumber 9.0
21
- ExposureProgram Program AE
22
- ISO 100
23
- ExifVersion 0221
24
- DateTimeOriginal 2005:10:06 15:41:08
25
- CreateDate 2005:10:06 15:41:08
26
- ComponentsConfiguration YCbCr
27
- BrightnessValue 9
28
- ExposureCompensation 0
29
- MaxApertureValue 3.5
30
- MeteringMode Multi-segment
31
- LightSource Unknown (0)
32
- Flash Off
33
- FocalLength 28.0mm
34
- SubjectLocation 1504 1000 256 304
35
- MakerNoteVersion MLT0
36
- MinoltaImageSize Large
37
- WhiteBalance Auto
38
- FocusMode Manual
39
- AFPoints Center
40
- ISOSetting 100
41
- FreeMemoryCardImages 127
42
- Rotation Horizontal (normal)
43
- ImageNumber 6
44
- NoiseReduction Unknown (2)
45
- ImageNumber2 60
46
- ZoneMatchingOn Off
47
- CompressedImageSize 2937828
48
- PreviewImageStart 2985987
49
- PreviewImageLength 36807
50
- SceneMode Standard
51
- ColorMode Natural sRGB
52
- MinoltaQuality Fine
53
- FlashExposureComp 0
54
- ImageStabilization On
55
- ZoneMatching ISO Setting Used
56
- ColorTemperature 0
57
- LensID Tamron 18-200, 28-300 or 80-300mm F3.5-6.3
58
- UserComment
59
- FlashpixVersion 0100
60
- ColorSpace sRGB
61
- ExifImageWidth 3008
62
- ExifImageLength 2000
63
- InteropIndex R98 - DCF basic file (sRGB)
64
- InteropVersion 0100
65
- CustomRendered Normal
66
- ExposureMode Auto
67
- DigitalZoomRatio 0
68
- FocalLengthIn35mmFormat 42mm
69
- SceneCaptureType Standard
70
- GainControl None
71
- Contrast Normal
72
- Saturation Normal
73
- Sharpness Normal
74
- Compression JPEG (old-style)
75
- ThumbnailOffset 40306
76
- ThumbnailLength 3002
77
- ImageWidth 3008
78
- ImageHeight 2000
79
- EncodingProcess Baseline DCT, Huffman coding
80
- BitsPerSample 8
81
- ColorComponents 3
82
- YCbCrSubSampling YCbCr4:2:2 (2 1)
83
- Aperture 9.0
84
- ImageSize 3008x2000
85
- PreviewImage (Binary data 36807 bytes, use -b option to extract)
86
- ScaleFactor35efl 1.5
87
- ShutterSpeed 1/200
88
- ThumbnailImage (Binary data 3002 bytes, use -b option to extract)
89
- CircleOfConfusion 0.020 mm
90
- FocalLength35efl 28.0mm (35mm equivalent: 42.0mm)
91
- HyperfocalDistance 4.35 m
92
- LightValue 14.0