multi_exiftool 0.0.1 → 0.1.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.
- data/CHANGELOG +1 -1
- data/LICENSE +21 -0
- data/Manifest +16 -23
- data/README +77 -16
- data/Rakefile +17 -38
- data/examples/01_simple_reading.rb +13 -0
- data/examples/02_simple_writing.rb +19 -0
- data/examples/03_reading_using_groups.rb +28 -0
- data/lib/multi_exiftool.rb +6 -38
- data/lib/multi_exiftool/executable.rb +67 -0
- data/lib/multi_exiftool/reader.rb +60 -0
- data/lib/multi_exiftool/values.rb +60 -0
- data/lib/multi_exiftool/writer.rb +55 -0
- data/multi_exiftool.gemspec +25 -16
- data/test/helper.rb +27 -0
- data/test/test_reader.rb +135 -0
- data/test/test_values.rb +75 -0
- data/test/test_values_using_groups.rb +61 -0
- data/test/test_writer.rb +102 -0
- metadata +49 -47
- data/COPYING +0 -165
- data/data/fixtures/read_non_existing_file.stderr +0 -1
- data/data/fixtures/read_non_existing_file.stdout +0 -0
- data/data/fixtures/read_one_file.stderr +0 -0
- data/data/fixtures/read_one_file.stdout +0 -92
- data/data/fixtures/read_two_files.stderr +0 -0
- data/data/fixtures/read_two_files.stdout +0 -212
- data/data/regression/read_command.rb +0 -12
- data/data/regression/read_command.rb.out +0 -16
- data/data/regression/write_command.rb +0 -16
- data/data/regression/write_command.rb.out +0 -40
- data/lib/multi_exiftool/command_generator.rb +0 -68
- data/lib/multi_exiftool/parser.rb +0 -43
- data/lib/multi_exiftool/read_object.rb +0 -57
- data/script/colorize.rb +0 -6
- data/script/generate_fixture.rb +0 -27
- data/test/test_command_generator.rb +0 -89
- data/test/test_helper.rb +0 -44
- data/test/test_parser.rb +0 -51
- data/test/test_read_object.rb +0 -36
File without changes
|
@@ -1,212 +0,0 @@
|
|
1
|
-
======== /home/janfri/test_photos/2008-02-16_0013.jpe
|
2
|
-
ExifToolVersion 7.03
|
3
|
-
FileName 2008-02-16_0013.jpe
|
4
|
-
Directory /home/janfri/test_photos
|
5
|
-
FileSize 2 MB
|
6
|
-
FileModifyDate 2008:02:16 16:10:54
|
7
|
-
FileType JPEG
|
8
|
-
MIMEType image/jpeg
|
9
|
-
ExifByteOrder Big-endian (Motorola)
|
10
|
-
ImageDescription KONICA MINOLTA DIGITAL CAMERA
|
11
|
-
Make KONICA MINOLTA
|
12
|
-
Model DYNAX 7D
|
13
|
-
Orientation Horizontal (normal)
|
14
|
-
XResolution 72
|
15
|
-
YResolution 72
|
16
|
-
ResolutionUnit inches
|
17
|
-
Software DYNAX 7D v1.10
|
18
|
-
ModifyDate 2008:02:16 16:10:52
|
19
|
-
YCbCrPositioning Centered
|
20
|
-
ExposureTime 1/250
|
21
|
-
FNumber 6.7
|
22
|
-
ExposureProgram Aperture-priority AE
|
23
|
-
ISO 100
|
24
|
-
ExifVersion 0221
|
25
|
-
DateTimeOriginal 2008:02:16 16:10:52
|
26
|
-
CreateDate 2008:02:16 16:10:52
|
27
|
-
ComponentsConfiguration YCbCr
|
28
|
-
BrightnessValue 8.5
|
29
|
-
ExposureCompensation 0
|
30
|
-
MaxApertureValue 6.7
|
31
|
-
MeteringMode Center-weighted average
|
32
|
-
LightSource Unknown (0)
|
33
|
-
Flash Off
|
34
|
-
FocalLength 300.0mm
|
35
|
-
SubjectLocation 1504 1000 256 304
|
36
|
-
MakerNoteVersion MLT0
|
37
|
-
MinoltaImageSize Large
|
38
|
-
WhiteBalance Auto
|
39
|
-
FocusMode Single-shot AF
|
40
|
-
AFPoints Center
|
41
|
-
ISOSetting Auto
|
42
|
-
FreeMemoryCardImages 49
|
43
|
-
Rotation Horizontal (normal)
|
44
|
-
ImageNumber 6
|
45
|
-
NoiseReduction Unknown (2)
|
46
|
-
ImageNumber2 304
|
47
|
-
ZoneMatchingOn Off
|
48
|
-
CompressedImageSize 2322879
|
49
|
-
PreviewImageStart 2372611
|
50
|
-
PreviewImageLength 46166
|
51
|
-
SceneMode Standard
|
52
|
-
ColorMode Adobe RGB
|
53
|
-
MinoltaQuality Fine
|
54
|
-
FlashExposureComp 0
|
55
|
-
ImageStabilization On
|
56
|
-
ZoneMatching ISO Setting Used
|
57
|
-
ColorTemperature 0
|
58
|
-
LensID Tamron 18-200, 28-300 or 80-300mm F3.5-6.3
|
59
|
-
UserComment
|
60
|
-
FlashpixVersion 0100
|
61
|
-
ColorSpace Uncalibrated
|
62
|
-
ExifImageWidth 3008
|
63
|
-
ExifImageLength 2000
|
64
|
-
InteropIndex R98 - DCF basic file (sRGB)
|
65
|
-
InteropVersion 0100
|
66
|
-
CustomRendered Normal
|
67
|
-
ExposureMode Auto
|
68
|
-
DigitalZoomRatio 0
|
69
|
-
FocalLengthIn35mmFormat 450mm
|
70
|
-
SceneCaptureType Standard
|
71
|
-
GainControl None
|
72
|
-
Contrast Normal
|
73
|
-
Saturation Normal
|
74
|
-
Sharpness Normal
|
75
|
-
Compression JPEG (old-style)
|
76
|
-
ThumbnailOffset 40306
|
77
|
-
ThumbnailLength 3729
|
78
|
-
ProfileCMMType Win
|
79
|
-
ProfileVersion 2.2.0
|
80
|
-
ProfileClass Display Device Profile
|
81
|
-
ColorSpaceData RGB
|
82
|
-
ProfileConnectionSpace XYZ
|
83
|
-
ProfileDateTime 2002:05:09 20:45:47
|
84
|
-
ProfileFileSignature acsp
|
85
|
-
PrimaryPlatform Microsoft Corporation
|
86
|
-
CMMFlags Not Embedded, Independent
|
87
|
-
DeviceManufacturer KMHD
|
88
|
-
DeviceModel
|
89
|
-
DeviceAttributes Reflective, Glossy, Positive, Color
|
90
|
-
RenderingIntent Perceptual
|
91
|
-
ConnectionSpaceIlluminant 0.96419 1 0.82487
|
92
|
-
ProfileCreator KMHD
|
93
|
-
ProfileID 0
|
94
|
-
ProfileCopyright Copyright 2002 Minolta Co.,Ltd.
|
95
|
-
ProfileDescription AdobeRGB1998 ((KONICA MINOLTA CAM
|
96
|
-
GreenTRC (Binary data 1036 bytes, use -b option to extract)
|
97
|
-
RedTRC (Binary data 1036 bytes, use -b option to extract)
|
98
|
-
BlueTRC (Binary data 1036 bytes, use -b option to extract)
|
99
|
-
RedMatrixColumn 0.6097 0.3111 0.01949
|
100
|
-
GreenMatrixColumn 0.20529 0.62569 0.0609
|
101
|
-
BlueMatrixColumn 0.14919 0.06319 0.7446
|
102
|
-
MediaWhitePoint 0.95045 1 1.08905
|
103
|
-
ImageWidth 3008
|
104
|
-
ImageHeight 2000
|
105
|
-
EncodingProcess Baseline DCT, Huffman coding
|
106
|
-
BitsPerSample 8
|
107
|
-
ColorComponents 3
|
108
|
-
YCbCrSubSampling YCbCr4:2:2 (2 1)
|
109
|
-
Aperture 6.7
|
110
|
-
ImageSize 3008x2000
|
111
|
-
PreviewImage (Binary data 46166 bytes, use -b option to extract)
|
112
|
-
ScaleFactor35efl 1.5
|
113
|
-
ShutterSpeed 1/250
|
114
|
-
ThumbnailImage (Binary data 3729 bytes, use -b option to extract)
|
115
|
-
CircleOfConfusion 0.020 mm
|
116
|
-
FocalLength35efl 300.0mm (35mm equivalent: 450.0mm)
|
117
|
-
HyperfocalDistance 670.61 m
|
118
|
-
LightValue 13.5
|
119
|
-
======== /home/janfri/test_photos/2008-03-01_0004.jpg
|
120
|
-
ExifToolVersion 7.03
|
121
|
-
FileName 2008-03-01_0004.jpg
|
122
|
-
Directory /home/janfri/test_photos
|
123
|
-
FileSize 2 MB
|
124
|
-
FileModifyDate 2008:03:13 17:47:05
|
125
|
-
FileType JPEG
|
126
|
-
MIMEType image/jpeg
|
127
|
-
ExifByteOrder Big-endian (Motorola)
|
128
|
-
ImageDescription KONICA MINOLTA DIGITAL CAMERA
|
129
|
-
Make KONICA MINOLTA
|
130
|
-
Model DYNAX 7D
|
131
|
-
Orientation Horizontal (normal)
|
132
|
-
XResolution 72
|
133
|
-
YResolution 72
|
134
|
-
ResolutionUnit inches
|
135
|
-
Software DYNAX 7D v1.10
|
136
|
-
ModifyDate 2008:03:01 13:23:22
|
137
|
-
YCbCrPositioning Centered
|
138
|
-
ExposureTime 1/60
|
139
|
-
FNumber 4.5
|
140
|
-
ExposureProgram Program AE
|
141
|
-
ISO 400
|
142
|
-
ExifVersion 0221
|
143
|
-
DateTimeOriginal 2008:03:01 13:23:22
|
144
|
-
CreateDate 2008:03:01 13:23:22
|
145
|
-
ComponentsConfiguration YCbCr
|
146
|
-
BrightnessValue 3.5
|
147
|
-
ExposureCompensation 0
|
148
|
-
MaxApertureValue 4.5
|
149
|
-
MeteringMode Center-weighted average
|
150
|
-
LightSource Unknown (0)
|
151
|
-
Flash On
|
152
|
-
FocalLength 75.0mm
|
153
|
-
SubjectLocation 1504 1000 256 304
|
154
|
-
MakerNoteVersion MLT0
|
155
|
-
MinoltaImageSize Large
|
156
|
-
WhiteBalance Auto
|
157
|
-
FocusMode Single-shot AF
|
158
|
-
AFPoints Center
|
159
|
-
ISOSetting Auto
|
160
|
-
FreeMemoryCardImages 15
|
161
|
-
Rotation Rotate 270 CW
|
162
|
-
ImageNumber 6
|
163
|
-
NoiseReduction Unknown (2)
|
164
|
-
ImageNumber2 304
|
165
|
-
ZoneMatchingOn Off
|
166
|
-
CompressedImageSize 2191918
|
167
|
-
PreviewImageStart 2241539
|
168
|
-
PreviewImageLength 35524
|
169
|
-
SceneMode Standard
|
170
|
-
ColorMode Natural sRGB
|
171
|
-
MinoltaQuality Fine
|
172
|
-
FlashExposureComp 0
|
173
|
-
ImageStabilization On
|
174
|
-
ZoneMatching ISO Setting Used
|
175
|
-
ColorTemperature 0
|
176
|
-
LensID Tamron 18-200, 28-300 or 80-300mm F3.5-6.3
|
177
|
-
UserComment
|
178
|
-
FlashpixVersion 0100
|
179
|
-
ColorSpace sRGB
|
180
|
-
ExifImageWidth 3008
|
181
|
-
ExifImageLength 2000
|
182
|
-
InteropIndex R98 - DCF basic file (sRGB)
|
183
|
-
InteropVersion 0100
|
184
|
-
CustomRendered Normal
|
185
|
-
ExposureMode Auto
|
186
|
-
DigitalZoomRatio 0
|
187
|
-
FocalLengthIn35mmFormat 112mm
|
188
|
-
SceneCaptureType Standard
|
189
|
-
GainControl Low gain up
|
190
|
-
Contrast Normal
|
191
|
-
Saturation Normal
|
192
|
-
Sharpness Normal
|
193
|
-
Compression JPEG (old-style)
|
194
|
-
ThumbnailOffset 40306
|
195
|
-
ThumbnailLength 3420
|
196
|
-
ImageWidth 3008
|
197
|
-
ImageHeight 2000
|
198
|
-
EncodingProcess Baseline DCT, Huffman coding
|
199
|
-
BitsPerSample 8
|
200
|
-
ColorComponents 3
|
201
|
-
YCbCrSubSampling YCbCr4:2:2 (2 1)
|
202
|
-
Aperture 4.5
|
203
|
-
ImageSize 3008x2000
|
204
|
-
PreviewImage (Binary data 35524 bytes, use -b option to extract)
|
205
|
-
ScaleFactor35efl 1.5
|
206
|
-
ShutterSpeed 1/60
|
207
|
-
ThumbnailImage (Binary data 3420 bytes, use -b option to extract)
|
208
|
-
CircleOfConfusion 0.020 mm
|
209
|
-
FocalLength35efl 75.0mm (35mm equivalent: 112.0mm)
|
210
|
-
HyperfocalDistance 62.13 m
|
211
|
-
LightValue 8.2
|
212
|
-
2 image files read
|
@@ -1,12 +0,0 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), %w(.. .. lib))
|
2
|
-
require 'multi_exiftool'
|
3
|
-
|
4
|
-
read_opts = [{}, {:numerical => true}, {:only => [:filename, :rotation, :orientation]}, {:numerical => true, :only => [:filename, :rotation, :orientation]}]
|
5
|
-
|
6
|
-
filenames = [['a.jpg', 'b.jpg', 'c.jpg'], ['hello world.tif'], ['a.jpg', 'b.jpg', 'c.jpg', 'hello world.tif'], ['a.jpg', 'b.jpg', 'c.jpg', 'hello world.tif', 'd.jpg']]
|
7
|
-
|
8
|
-
read_opts.each do |opts|
|
9
|
-
filenames.each do |fnames|
|
10
|
-
puts MultiExiftool::CommandGenerator.read_command(fnames, opts)
|
11
|
-
end
|
12
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
exiftool -s -t a.jpg b.jpg c.jpg
|
2
|
-
exiftool -s -t "hello world.tif"
|
3
|
-
exiftool -s -t a.jpg b.jpg c.jpg "hello world.tif"
|
4
|
-
exiftool -s -t a.jpg b.jpg c.jpg "hello world.tif" d.jpg
|
5
|
-
exiftool -s -t -n a.jpg b.jpg c.jpg
|
6
|
-
exiftool -s -t -n "hello world.tif"
|
7
|
-
exiftool -s -t -n a.jpg b.jpg c.jpg "hello world.tif"
|
8
|
-
exiftool -s -t -n a.jpg b.jpg c.jpg "hello world.tif" d.jpg
|
9
|
-
exiftool -s -t -filename -rotation -orientation a.jpg b.jpg c.jpg
|
10
|
-
exiftool -s -t -filename -rotation -orientation "hello world.tif"
|
11
|
-
exiftool -s -t -filename -rotation -orientation a.jpg b.jpg c.jpg "hello world.tif"
|
12
|
-
exiftool -s -t -filename -rotation -orientation a.jpg b.jpg c.jpg "hello world.tif" d.jpg
|
13
|
-
exiftool -s -t -n -filename -rotation -orientation a.jpg b.jpg c.jpg
|
14
|
-
exiftool -s -t -n -filename -rotation -orientation "hello world.tif"
|
15
|
-
exiftool -s -t -n -filename -rotation -orientation a.jpg b.jpg c.jpg "hello world.tif"
|
16
|
-
exiftool -s -t -n -filename -rotation -orientation a.jpg b.jpg c.jpg "hello world.tif" d.jpg
|
@@ -1,16 +0,0 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), %w(.. .. lib))
|
2
|
-
require 'multi_exiftool'
|
3
|
-
|
4
|
-
write_opts = [{}, {:numerical => true}]
|
5
|
-
|
6
|
-
changesets = [{}, {:author => 'janfri'}, {:author => 'janfri', :comment => 'some comment'}, {:author => 'janfri', :comment => 'some comment', :keywords => [:a, :b, :c]}, {:orientation => 1}]
|
7
|
-
|
8
|
-
filenames = [['a.jpg', 'b.jpg', 'c.jpg'], ['hello world.tif'], ['a.jpg', 'b.jpg', 'c.jpg', 'hello world.tif'], ['a.jpg', 'b.jpg', 'c.jpg', 'hello world.tif', 'd.jpg']]
|
9
|
-
|
10
|
-
write_opts.each do |opts|
|
11
|
-
changesets.each do |cs|
|
12
|
-
filenames.each do |fnames|
|
13
|
-
puts MultiExiftool::CommandGenerator.write_command(cs, fnames, opts)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
exiftool -overwrite_original a.jpg b.jpg c.jpg
|
2
|
-
exiftool -overwrite_original "hello world.tif"
|
3
|
-
exiftool -overwrite_original a.jpg b.jpg c.jpg "hello world.tif"
|
4
|
-
exiftool -overwrite_original a.jpg b.jpg c.jpg "hello world.tif" d.jpg
|
5
|
-
exiftool -overwrite_original -author=janfri a.jpg b.jpg c.jpg
|
6
|
-
exiftool -overwrite_original -author=janfri "hello world.tif"
|
7
|
-
exiftool -overwrite_original -author=janfri a.jpg b.jpg c.jpg "hello world.tif"
|
8
|
-
exiftool -overwrite_original -author=janfri a.jpg b.jpg c.jpg "hello world.tif" d.jpg
|
9
|
-
exiftool -overwrite_original -author=janfri -comment="some comment" a.jpg b.jpg c.jpg
|
10
|
-
exiftool -overwrite_original -author=janfri -comment="some comment" "hello world.tif"
|
11
|
-
exiftool -overwrite_original -author=janfri -comment="some comment" a.jpg b.jpg c.jpg "hello world.tif"
|
12
|
-
exiftool -overwrite_original -author=janfri -comment="some comment" a.jpg b.jpg c.jpg "hello world.tif" d.jpg
|
13
|
-
exiftool -overwrite_original -author=janfri -comment="some comment" -keywords=a -keywords=b -keywords=c a.jpg b.jpg c.jpg
|
14
|
-
exiftool -overwrite_original -author=janfri -comment="some comment" -keywords=a -keywords=b -keywords=c "hello world.tif"
|
15
|
-
exiftool -overwrite_original -author=janfri -comment="some comment" -keywords=a -keywords=b -keywords=c a.jpg b.jpg c.jpg "hello world.tif"
|
16
|
-
exiftool -overwrite_original -author=janfri -comment="some comment" -keywords=a -keywords=b -keywords=c a.jpg b.jpg c.jpg "hello world.tif" d.jpg
|
17
|
-
exiftool -overwrite_original -orientation=1 a.jpg b.jpg c.jpg
|
18
|
-
exiftool -overwrite_original -orientation=1 "hello world.tif"
|
19
|
-
exiftool -overwrite_original -orientation=1 a.jpg b.jpg c.jpg "hello world.tif"
|
20
|
-
exiftool -overwrite_original -orientation=1 a.jpg b.jpg c.jpg "hello world.tif" d.jpg
|
21
|
-
exiftool -overwrite_original -n a.jpg b.jpg c.jpg
|
22
|
-
exiftool -overwrite_original -n "hello world.tif"
|
23
|
-
exiftool -overwrite_original -n a.jpg b.jpg c.jpg "hello world.tif"
|
24
|
-
exiftool -overwrite_original -n a.jpg b.jpg c.jpg "hello world.tif" d.jpg
|
25
|
-
exiftool -overwrite_original -n -author=janfri a.jpg b.jpg c.jpg
|
26
|
-
exiftool -overwrite_original -n -author=janfri "hello world.tif"
|
27
|
-
exiftool -overwrite_original -n -author=janfri a.jpg b.jpg c.jpg "hello world.tif"
|
28
|
-
exiftool -overwrite_original -n -author=janfri a.jpg b.jpg c.jpg "hello world.tif" d.jpg
|
29
|
-
exiftool -overwrite_original -n -author=janfri -comment="some comment" a.jpg b.jpg c.jpg
|
30
|
-
exiftool -overwrite_original -n -author=janfri -comment="some comment" "hello world.tif"
|
31
|
-
exiftool -overwrite_original -n -author=janfri -comment="some comment" a.jpg b.jpg c.jpg "hello world.tif"
|
32
|
-
exiftool -overwrite_original -n -author=janfri -comment="some comment" a.jpg b.jpg c.jpg "hello world.tif" d.jpg
|
33
|
-
exiftool -overwrite_original -n -author=janfri -comment="some comment" -keywords=a -keywords=b -keywords=c a.jpg b.jpg c.jpg
|
34
|
-
exiftool -overwrite_original -n -author=janfri -comment="some comment" -keywords=a -keywords=b -keywords=c "hello world.tif"
|
35
|
-
exiftool -overwrite_original -n -author=janfri -comment="some comment" -keywords=a -keywords=b -keywords=c a.jpg b.jpg c.jpg "hello world.tif"
|
36
|
-
exiftool -overwrite_original -n -author=janfri -comment="some comment" -keywords=a -keywords=b -keywords=c a.jpg b.jpg c.jpg "hello world.tif" d.jpg
|
37
|
-
exiftool -overwrite_original -n -orientation=1 a.jpg b.jpg c.jpg
|
38
|
-
exiftool -overwrite_original -n -orientation=1 "hello world.tif"
|
39
|
-
exiftool -overwrite_original -n -orientation=1 a.jpg b.jpg c.jpg "hello world.tif"
|
40
|
-
exiftool -overwrite_original -n -orientation=1 a.jpg b.jpg c.jpg "hello world.tif" d.jpg
|
@@ -1,68 +0,0 @@
|
|
1
|
-
module MultiExiftool
|
2
|
-
|
3
|
-
module CommandGenerator
|
4
|
-
|
5
|
-
@command = 'exiftool'
|
6
|
-
@std_opts_read = '-s -t'
|
7
|
-
@std_opts_write = '-overwrite_original'
|
8
|
-
|
9
|
-
class << self
|
10
|
-
|
11
|
-
attr_reader :std_opts_read, :std_opts_write
|
12
|
-
attr_accessor :command
|
13
|
-
|
14
|
-
def options_array opts={}
|
15
|
-
arr = []
|
16
|
-
arr << '-n' if opts[:numerical]
|
17
|
-
arr
|
18
|
-
end
|
19
|
-
|
20
|
-
def write_tag_array change_set
|
21
|
-
arr = []
|
22
|
-
change_set.to_hash.each do |tag, val|
|
23
|
-
val_array = val.kind_of?(Array) ? val : [val]
|
24
|
-
val_array.each do |v|
|
25
|
-
arr << "-#{tag}=#{escape(v)}"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
arr
|
29
|
-
end
|
30
|
-
|
31
|
-
def read_tag_array tags
|
32
|
-
arr = []
|
33
|
-
tags.each do |tag|
|
34
|
-
arr << "-#{tag}"
|
35
|
-
end
|
36
|
-
arr
|
37
|
-
end
|
38
|
-
|
39
|
-
def filenames_array filenames
|
40
|
-
filenames.flatten.map {|fn| escape(fn) }
|
41
|
-
end
|
42
|
-
|
43
|
-
def read_command *args
|
44
|
-
files, opts = parse_args(args)
|
45
|
-
only = opts[:only] || []
|
46
|
-
[command, std_opts_read, options_array(opts), read_tag_array(only), filenames_array(files)].flatten.join(' ')
|
47
|
-
end
|
48
|
-
|
49
|
-
def write_command change_set, *args
|
50
|
-
files, opts = parse_args(args)
|
51
|
-
[command, std_opts_write, options_array(opts), write_tag_array(change_set), filenames_array(files)].flatten.join(' ')
|
52
|
-
end
|
53
|
-
|
54
|
-
def parse_args(args)
|
55
|
-
opts = args.last.kind_of?(Hash) ? args.pop : {}
|
56
|
-
[args, opts]
|
57
|
-
end
|
58
|
-
|
59
|
-
def escape string
|
60
|
-
return string unless string =~ /[ \\]/
|
61
|
-
'"' << string.gsub("\\") { "\\\\" } << '"'
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
module MultiExiftool
|
2
|
-
|
3
|
-
module Parser
|
4
|
-
|
5
|
-
# :stopdoc:
|
6
|
-
REGEXP_TAGLINE = /^(\w+)\t(.*)$/.freeze
|
7
|
-
REGEXP_STRIPLINE = /^={8} /.freeze
|
8
|
-
# :startdoc:
|
9
|
-
|
10
|
-
def self.parse stdout, stderr
|
11
|
-
result = []
|
12
|
-
image_info = {}
|
13
|
-
while !stdout.eof
|
14
|
-
line = stdout.readline.chomp
|
15
|
-
case line
|
16
|
-
when REGEXP_TAGLINE
|
17
|
-
image_info[$1] = $2
|
18
|
-
when REGEXP_STRIPLINE
|
19
|
-
unless image_info.empty?
|
20
|
-
result << Result.new(image_info, {})
|
21
|
-
end
|
22
|
-
image_info = {}
|
23
|
-
end
|
24
|
-
end
|
25
|
-
unless image_info.empty?
|
26
|
-
result << Result.new(image_info, {})
|
27
|
-
end
|
28
|
-
result
|
29
|
-
end
|
30
|
-
|
31
|
-
class Result
|
32
|
-
|
33
|
-
attr_reader :data, :errors
|
34
|
-
|
35
|
-
def initialize data, errors
|
36
|
-
@data, @errors = data.freeze, errors.freeze
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
module MultiExiftool
|
2
|
-
|
3
|
-
class ReadObject
|
4
|
-
|
5
|
-
def initialize values={}
|
6
|
-
@values = {}
|
7
|
-
values.each do |tag, val|
|
8
|
-
@values[unify(tag)] = val
|
9
|
-
end
|
10
|
-
@values.freeze
|
11
|
-
end
|
12
|
-
|
13
|
-
def each
|
14
|
-
@values.each do |tag, val|
|
15
|
-
yield tag, convert(val)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def [] tag
|
20
|
-
convert(@values[unify(tag)])
|
21
|
-
end
|
22
|
-
|
23
|
-
class << self
|
24
|
-
attr_accessor :converting_rules
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def unify tag
|
30
|
-
tag.gsub(/[\-_]/, '').downcase
|
31
|
-
end
|
32
|
-
|
33
|
-
def convert val
|
34
|
-
result = val
|
35
|
-
ReadObject.converting_rules.each do |test, proc|
|
36
|
-
if test === val
|
37
|
-
result = proc.call(val)
|
38
|
-
break
|
39
|
-
end
|
40
|
-
end
|
41
|
-
result
|
42
|
-
end
|
43
|
-
|
44
|
-
def method_missing sym, *args
|
45
|
-
name = unify(sym.id2name)
|
46
|
-
self[name]
|
47
|
-
end
|
48
|
-
|
49
|
-
@converting_rules = []
|
50
|
-
|
51
|
-
@converting_rules << [/^0+\d+$/, lambda {|val| val}]
|
52
|
-
@converting_rules << [/^[+\-]?\d+$/, lambda {|val| val.to_i}]
|
53
|
-
@converting_rules << [/^[+\-]?\d+\.\d+$/, lambda {|val| val.to_f}]
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|