exifr 0.10.6 → 0.10.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +6 -0
- data/{README → README.rdoc} +1 -1
- data/Rakefile +7 -38
- data/lib/exifr.rb +2 -2
- data/lib/jpeg.rb +23 -8
- data/lib/tiff.rb +64 -44
- data/tests/{test_jpeg.rb → jpeg_test.rb} +17 -11
- data/tests/test_helper.rb +2 -2
- data/tests/{test_tiff.rb → tiff_test.rb} +28 -23
- metadata +15 -13
data/CHANGELOG
CHANGED
data/{README → README.rdoc}
RENAMED
data/Rakefile
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
# Copyright (c) 2006, 2007 - R.W. van 't Veer
|
1
|
+
# Copyright (c) 2006, 2007, 2008 - R.W. van 't Veer
|
2
2
|
|
3
3
|
require 'rake/rdoctask'
|
4
|
-
require 'rake/gempackagetask'
|
5
4
|
require 'rake/testtask'
|
6
5
|
|
7
6
|
task :default => :test
|
@@ -11,47 +10,17 @@ task :site => :rdoc do
|
|
11
10
|
system 'rsync -av --delete doc/ remvee@rubyforge.org:/var/www/gforge-projects/exifr'
|
12
11
|
end
|
13
12
|
|
14
|
-
desc "Tag current trunk. Use VERSION to provide a version spec."
|
15
|
-
task :tag do
|
16
|
-
version = ENV['VERSION'] or raise 'provide VERSION'
|
17
|
-
base = 'svn+ssh://remvee@rubyforge.org/var/svn/exifr'
|
18
|
-
trunk, tag = base + "/trunk", base + "/tags/#{version}"
|
19
|
-
system *(%w(svn copy -m) << "tagged release #{version}" << trunk << tag)
|
20
|
-
end
|
21
|
-
|
22
|
-
spec = Gem::Specification.new do |s|
|
23
|
-
s.name = 'exifr'
|
24
|
-
s.version = '0.10.6'
|
25
|
-
s.author = "R.W. van 't Veer"
|
26
|
-
s.email = 'remco@remvee.net'
|
27
|
-
s.homepage = 'http://exifr.rubyforge.org/'
|
28
|
-
s.summary = 'EXIF Reader is a module to read EXIF from JPEG images.'
|
29
|
-
|
30
|
-
s.autorequire = 'exifr'
|
31
|
-
s.files = FileList['Rakefile', '{bin,lib,tests}/**/*'].exclude('rdoc').to_a
|
32
|
-
|
33
|
-
s.has_rdoc = true
|
34
|
-
s.extra_rdoc_files = ['README', 'CHANGELOG']
|
35
|
-
|
36
|
-
s.bindir = 'bin'
|
37
|
-
s.executables = ['exifr']
|
38
|
-
end
|
39
|
-
|
40
|
-
Rake::GemPackageTask.new(spec) do |pkg|
|
41
|
-
pkg.need_tar = true
|
42
|
-
end
|
43
|
-
|
44
13
|
Rake::RDocTask.new do |rd|
|
45
14
|
rd.title = 'EXIF Reader for Ruby API Documentation'
|
46
|
-
rd.main = "README"
|
15
|
+
rd.main = "README.rdoc"
|
47
16
|
rd.rdoc_dir = "doc/api"
|
48
|
-
rd.rdoc_files.include("README", "lib/**/*.rb")
|
17
|
+
rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
|
49
18
|
end
|
50
19
|
|
51
20
|
|
52
21
|
Rake::TestTask.new do |t|
|
53
22
|
t.libs << 'lib' << 'tests'
|
54
|
-
t.test_files = FileList['tests
|
23
|
+
t.test_files = FileList['tests/*_test.rb']
|
55
24
|
end
|
56
25
|
|
57
26
|
begin
|
@@ -59,12 +28,12 @@ begin
|
|
59
28
|
|
60
29
|
Rcov::RcovTask.new do |t|
|
61
30
|
t.libs << 'lib' << 'tests'
|
62
|
-
t.test_files = FileList['tests
|
31
|
+
t.test_files = FileList['tests/*_test.rb']
|
63
32
|
end
|
64
33
|
|
65
34
|
desc 'Remove all artifacts left by testing and packaging'
|
66
|
-
task :clean => [:
|
35
|
+
task :clean => [:clobber_rdoc, :clobber_rcov]
|
67
36
|
rescue LoadError
|
68
37
|
desc 'Remove all artifacts left by testing and packaging'
|
69
|
-
task :clean => [:
|
38
|
+
task :clean => [:clobber_rdoc]
|
70
39
|
end
|
data/lib/exifr.rb
CHANGED
data/lib/jpeg.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2006, 2007 - R.W. van 't Veer
|
1
|
+
# Copyright (c) 2006, 2007, 2008 - R.W. van 't Veer
|
2
2
|
|
3
3
|
require 'stringio'
|
4
4
|
|
@@ -34,20 +34,35 @@ module EXIFR
|
|
34
34
|
def exif?
|
35
35
|
!exif.nil?
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
# Return thumbnail data when available.
|
39
39
|
def thumbnail
|
40
40
|
@exif && @exif.jpeg_thumbnails && @exif.jpeg_thumbnails.first
|
41
41
|
end
|
42
42
|
|
43
|
-
# Dispatch to EXIF. When no EXIF data is available but the
|
44
|
-
# for EXIF data +nil+ will be returned.
|
43
|
+
# Dispatch to EXIF. When no EXIF data is available but the
|
44
|
+
# +method+ does exist for EXIF data +nil+ will be returned.
|
45
45
|
def method_missing(method, *args)
|
46
46
|
super unless args.empty?
|
47
|
-
super unless TIFF::TAGS.include?(method)
|
47
|
+
super unless TIFF::TAGS.include?(method.to_s)
|
48
48
|
@exif.send method if @exif
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
|
+
def respond_to?(method) # :nodoc:
|
52
|
+
super || TIFF::TAGS.include?(method.to_s)
|
53
|
+
end
|
54
|
+
|
55
|
+
def methods # :nodoc:
|
56
|
+
super + TIFF::TAGS
|
57
|
+
end
|
58
|
+
|
59
|
+
class << self
|
60
|
+
alias instance_methods_without_jpeg_extras instance_methods
|
61
|
+
def instance_methods(include_super = true) # :nodoc:
|
62
|
+
instance_methods_without_jpeg_extras(include_super) + TIFF::TAGS
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
51
66
|
private
|
52
67
|
def examine(io)
|
53
68
|
class << io
|
@@ -78,10 +93,10 @@ module EXIFR
|
|
78
93
|
end
|
79
94
|
|
80
95
|
@comment = @comment.first if @comment && @comment.size == 1
|
81
|
-
|
96
|
+
|
82
97
|
if app1 = app1s.find { |d| d[0..5] == "Exif\0\0" }
|
83
98
|
@exif = TIFF.new(StringIO.new(app1[6..-1]))
|
84
99
|
end
|
85
100
|
end
|
86
101
|
end
|
87
|
-
end
|
102
|
+
end
|
data/lib/tiff.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2007 - R.W. van 't Veer
|
1
|
+
# Copyright (c) 2007, 2008 - R.W. van 't Veer
|
2
2
|
|
3
3
|
require 'rational'
|
4
4
|
|
@@ -36,10 +36,10 @@ module EXIFR
|
|
36
36
|
# EXIFR::TIFF.new('DSC_0218.TIF').orientation # => EXIFR::TIFF::Orientation
|
37
37
|
class TIFF
|
38
38
|
include Enumerable
|
39
|
-
|
39
|
+
|
40
40
|
# JPEG thumbnails
|
41
41
|
attr_reader :jpeg_thumbnails
|
42
|
-
|
42
|
+
|
43
43
|
TAG_MAPPING = {} # :nodoc:
|
44
44
|
TAG_MAPPING.merge!({
|
45
45
|
:image => {
|
@@ -140,7 +140,7 @@ module EXIFR
|
|
140
140
|
0x8769 => :exif,
|
141
141
|
0x8825 => :gps,
|
142
142
|
},
|
143
|
-
|
143
|
+
|
144
144
|
:exif => {
|
145
145
|
0x829a => :exposure_time,
|
146
146
|
0x829d => :f_number,
|
@@ -199,7 +199,7 @@ module EXIFR
|
|
199
199
|
0xa40c => :subject_distance_range,
|
200
200
|
0xa420 => :image_unique_id
|
201
201
|
},
|
202
|
-
|
202
|
+
|
203
203
|
:gps => {
|
204
204
|
0x0000 => :gps_version_id,
|
205
205
|
0x0001 => :gps_latitude_ref,
|
@@ -235,7 +235,7 @@ module EXIFR
|
|
235
235
|
},
|
236
236
|
})
|
237
237
|
IFD_TAGS = [:image, :exif, :gps] # :nodoc:
|
238
|
-
|
238
|
+
|
239
239
|
time_proc = proc do |value|
|
240
240
|
if value =~ /^(\d{4}):(\d\d):(\d\d) (\d\d):(\d\d):(\d\d)$/
|
241
241
|
Time.mktime($1.to_i, $2.to_i, $3.to_i, $4.to_i, $5.to_i, $6.to_i) rescue nil
|
@@ -243,18 +243,18 @@ module EXIFR
|
|
243
243
|
value
|
244
244
|
end
|
245
245
|
end
|
246
|
-
|
246
|
+
|
247
247
|
# The orientation of the image with respect to the rows and columns.
|
248
248
|
class Orientation
|
249
249
|
def initialize(value, type) # :nodoc:
|
250
250
|
@value, @type = value, type
|
251
251
|
end
|
252
|
-
|
252
|
+
|
253
253
|
# Field value.
|
254
254
|
def to_i
|
255
255
|
@value
|
256
256
|
end
|
257
|
-
|
257
|
+
|
258
258
|
# Rotate and/or flip for proper viewing.
|
259
259
|
def transform_rmagick(img)
|
260
260
|
case @type
|
@@ -269,12 +269,12 @@ module EXIFR
|
|
269
269
|
img
|
270
270
|
end
|
271
271
|
end
|
272
|
-
|
272
|
+
|
273
273
|
def ==(other) # :nodoc:
|
274
274
|
Orientation === other && to_i == other.to_i
|
275
275
|
end
|
276
276
|
end
|
277
|
-
|
277
|
+
|
278
278
|
ORIENTATIONS = [] # :nodoc:
|
279
279
|
[
|
280
280
|
nil,
|
@@ -290,7 +290,7 @@ module EXIFR
|
|
290
290
|
next unless type
|
291
291
|
const_set("#{type}Orientation", ORIENTATIONS[index] = Orientation.new(index, type))
|
292
292
|
end
|
293
|
-
|
293
|
+
|
294
294
|
ADAPTERS = Hash.new { proc { |v| v } } # :nodoc:
|
295
295
|
ADAPTERS.merge!({
|
296
296
|
:date_time_original => time_proc,
|
@@ -298,29 +298,32 @@ module EXIFR
|
|
298
298
|
:date_time => time_proc,
|
299
299
|
:orientation => proc { |v| ORIENTATIONS[v] }
|
300
300
|
})
|
301
|
-
|
301
|
+
|
302
302
|
# Names for all recognized TIFF fields.
|
303
|
-
TAGS = [TAG_MAPPING.keys, TAG_MAPPING.values.map{|
|
304
|
-
|
303
|
+
TAGS = ([TAG_MAPPING.keys, TAG_MAPPING.values.map{|v|v.values}].flatten.uniq - IFD_TAGS).map{|v|v.to_s}
|
304
|
+
|
305
305
|
# +file+ is a filename or an IO object.
|
306
306
|
def initialize(file)
|
307
307
|
data = file.respond_to?(:read) ? file.read : File.open(file, 'rb') { |io| io.read }
|
308
|
-
|
308
|
+
|
309
309
|
class << data
|
310
310
|
attr_accessor :short, :long
|
311
311
|
def readshort(pos); self[pos..(pos + 1)].unpack(@short)[0]; end
|
312
312
|
def readlong(pos); self[pos..(pos + 3)].unpack(@long)[0]; end
|
313
313
|
end
|
314
|
-
|
314
|
+
|
315
315
|
case data[0..1]
|
316
316
|
when 'II'; data.short, data.long = 'v', 'V'
|
317
317
|
when 'MM'; data.short, data.long = 'n', 'N'
|
318
318
|
else; raise 'no II or MM marker found'
|
319
319
|
end
|
320
|
-
|
320
|
+
|
321
321
|
@ifds = [IFD.new(data)]
|
322
|
-
while ifd = @ifds.last.next
|
323
|
-
|
322
|
+
while ifd = @ifds.last.next
|
323
|
+
break if @ifds.find{|i| i.offset == ifd.offset}
|
324
|
+
@ifds << ifd
|
325
|
+
end
|
326
|
+
|
324
327
|
@jpeg_thumbnails = @ifds.map do |ifd|
|
325
328
|
if ifd.jpeg_interchange_format && ifd.jpeg_interchange_format_length
|
326
329
|
start, length = ifd.jpeg_interchange_format, ifd.jpeg_interchange_format_length
|
@@ -328,54 +331,71 @@ module EXIFR
|
|
328
331
|
end
|
329
332
|
end.compact
|
330
333
|
end
|
331
|
-
|
334
|
+
|
332
335
|
# Number of images.
|
333
336
|
def size
|
334
337
|
@ifds.size
|
335
338
|
end
|
336
|
-
|
339
|
+
|
337
340
|
# Yield for each image.
|
338
341
|
def each
|
339
342
|
@ifds.each { |ifd| yield ifd }
|
340
343
|
end
|
341
|
-
|
344
|
+
|
342
345
|
# Get +index+ image.
|
343
346
|
def [](index)
|
344
347
|
index.is_a?(Symbol) ? to_hash[index] : @ifds[index]
|
345
348
|
end
|
346
|
-
|
349
|
+
|
347
350
|
# Dispatch to first image.
|
348
351
|
def method_missing(method, *args)
|
349
352
|
super unless args.empty?
|
350
|
-
|
353
|
+
|
351
354
|
if @ifds.first.respond_to?(method)
|
352
355
|
@ifds.first.send(method)
|
353
|
-
elsif TAGS.include?(method)
|
356
|
+
elsif TAGS.include?(method.to_s)
|
354
357
|
@ifds.first.to_hash[method]
|
355
358
|
else
|
356
359
|
super
|
357
360
|
end
|
358
361
|
end
|
359
|
-
|
362
|
+
|
363
|
+
def respond_to?(method) # :nodoc:
|
364
|
+
super ||
|
365
|
+
(@ifds && @ifds.first && @ifds.first.respond_to?(method)) ||
|
366
|
+
TAGS.include?(method.to_s)
|
367
|
+
end
|
368
|
+
|
369
|
+
def methods # :nodoc:
|
370
|
+
(super + TAGS + IFD.instance_methods(false)).uniq
|
371
|
+
end
|
372
|
+
|
373
|
+
class << self
|
374
|
+
alias instance_methods_without_tiff_extras instance_methods
|
375
|
+
def instance_methods(include_super = true) # :nodoc:
|
376
|
+
(instance_methods_without_tiff_extras(include_super) + TAGS + IFD.instance_methods(false)).uniq
|
377
|
+
end
|
378
|
+
end
|
379
|
+
|
360
380
|
# Convenience method to access image width.
|
361
381
|
def width; @ifds.first.width; end
|
362
382
|
|
363
383
|
# Convenience method to access image height.
|
364
384
|
def height; @ifds.first.height; end
|
365
|
-
|
385
|
+
|
366
386
|
# Get a hash presentation of the (first) image.
|
367
387
|
def to_hash; @ifds.first.to_hash; end
|
368
|
-
|
388
|
+
|
369
389
|
def inspect # :nodoc:
|
370
390
|
@ifds.inspect
|
371
391
|
end
|
372
|
-
|
392
|
+
|
373
393
|
class IFD # :nodoc:
|
374
|
-
attr_reader :type, :fields
|
394
|
+
attr_reader :type, :fields, :offset
|
375
395
|
|
376
396
|
def initialize(data, offset = nil, type = :image)
|
377
397
|
@data, @offset, @type, @fields = data, offset, type, {}
|
378
|
-
|
398
|
+
|
379
399
|
pos = offset || @data.readlong(4)
|
380
400
|
num = @data.readshort(pos)
|
381
401
|
pos += 2
|
@@ -387,15 +407,15 @@ module EXIFR
|
|
387
407
|
|
388
408
|
@offset_next = @data.readlong(pos)
|
389
409
|
end
|
390
|
-
|
410
|
+
|
391
411
|
def method_missing(method, *args)
|
392
|
-
super unless args.empty? && TAGS.include?(method)
|
412
|
+
super unless args.empty? && TAGS.include?(method.to_s)
|
393
413
|
to_hash[method]
|
394
414
|
end
|
395
|
-
|
415
|
+
|
396
416
|
def width; image_width; end
|
397
417
|
def height; image_length; end
|
398
|
-
|
418
|
+
|
399
419
|
def to_hash
|
400
420
|
@hash ||= begin
|
401
421
|
result = @fields.dup
|
@@ -414,22 +434,22 @@ module EXIFR
|
|
414
434
|
end
|
415
435
|
|
416
436
|
def next?
|
417
|
-
@offset_next != 0 && @offset_next < @data.size
|
437
|
+
@offset_next != 0 && @offset_next < @data.size
|
418
438
|
end
|
419
|
-
|
439
|
+
|
420
440
|
def next
|
421
441
|
IFD.new(@data, @offset_next) if next?
|
422
442
|
end
|
423
|
-
|
443
|
+
|
424
444
|
def to_yaml_properties
|
425
445
|
['@fields']
|
426
446
|
end
|
427
|
-
|
447
|
+
|
428
448
|
private
|
429
449
|
def add_field(field)
|
430
450
|
return unless tag = TAG_MAPPING[@type][field.tag]
|
431
451
|
return if @fields[tag]
|
432
|
-
|
452
|
+
|
433
453
|
if IFD_TAGS.include? tag
|
434
454
|
@fields[tag] = IFD.new(@data, field.offset, tag)
|
435
455
|
else
|
@@ -444,7 +464,7 @@ module EXIFR
|
|
444
464
|
|
445
465
|
def initialize(data, pos)
|
446
466
|
@tag, count, @offset = data.readshort(pos), data.readlong(pos + 4), data.readlong(pos + 8)
|
447
|
-
|
467
|
+
|
448
468
|
case data.readshort(pos + 2)
|
449
469
|
when 1, 6 # byte, signed byte
|
450
470
|
# TODO handle signed bytes
|
@@ -467,7 +487,7 @@ module EXIFR
|
|
467
487
|
if f[1] == 0 # allow NaN and Infinity
|
468
488
|
f[0].to_f.quo(f[1])
|
469
489
|
else
|
470
|
-
Rational.reduce(*f)
|
490
|
+
Rational.respond_to?(:reduce) ? Rational.reduce(*f) : f[0].quo(f[1])
|
471
491
|
end
|
472
492
|
end
|
473
493
|
end
|
@@ -480,4 +500,4 @@ module EXIFR
|
|
480
500
|
end
|
481
501
|
end
|
482
502
|
end
|
483
|
-
end
|
503
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
#
|
3
|
-
# Copyright (c) 2006, 2007 - R.W. van 't Veer
|
3
|
+
# Copyright (c) 2006, 2007, 2008 - R.W. van 't Veer
|
4
4
|
|
5
5
|
require File.join(File.dirname(__FILE__), 'test_helper')
|
6
6
|
|
7
|
-
class
|
7
|
+
class JPEGTest < Test::Unit::TestCase
|
8
8
|
def test_initialize
|
9
9
|
all_test_jpegs.each do |fname|
|
10
10
|
assert_nothing_raised do
|
@@ -18,7 +18,7 @@ class TestJPEG < Test::Unit::TestCase
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
def test_size
|
23
23
|
j = JPEG.new(f('image.jpg'))
|
24
24
|
assert_equal j.width, 100
|
@@ -32,35 +32,41 @@ class TestJPEG < Test::Unit::TestCase
|
|
32
32
|
assert_equal j.width, 1
|
33
33
|
assert_equal j.height, 1
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
def test_comment
|
37
37
|
assert_equal JPEG.new(f('image.jpg')).comment, "Here's a comment!"
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
def test_exif
|
41
41
|
assert ! JPEG.new(f('image.jpg')).exif?
|
42
42
|
assert JPEG.new(f('exif.jpg')).exif?
|
43
43
|
assert_not_nil JPEG.new(f('exif.jpg')).exif.date_time
|
44
44
|
assert_not_nil JPEG.new(f('exif.jpg')).exif.f_number
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
def test_exif_dispatch
|
48
48
|
j = JPEG.new(f('exif.jpg'))
|
49
|
+
|
50
|
+
assert JPEG.instance_methods.include?('date_time')
|
51
|
+
assert j.methods.include?('date_time')
|
52
|
+
assert j.respond_to?(:date_time)
|
53
|
+
assert j.respond_to?('date_time')
|
49
54
|
assert_not_nil j.date_time
|
50
55
|
assert_kind_of Time, j.date_time
|
56
|
+
|
51
57
|
assert_not_nil j.f_number
|
52
58
|
assert_kind_of Rational, j.f_number
|
53
59
|
end
|
54
|
-
|
60
|
+
|
55
61
|
def test_no_method_error
|
56
62
|
assert_nothing_raised { JPEG.new(f('image.jpg')).f_number }
|
57
63
|
assert_raise(NoMethodError) { JPEG.new(f('image.jpg')).foo }
|
58
64
|
end
|
59
|
-
|
65
|
+
|
60
66
|
def test_multiple_app1
|
61
67
|
assert JPEG.new(f('multiple-app1.jpg')).exif?
|
62
68
|
end
|
63
|
-
|
69
|
+
|
64
70
|
def test_thumbnail
|
65
71
|
count = 0
|
66
72
|
all_test_jpegs.each do |fname|
|
@@ -72,7 +78,7 @@ class TestJPEG < Test::Unit::TestCase
|
|
72
78
|
count += 1
|
73
79
|
end
|
74
80
|
end
|
75
|
-
|
81
|
+
|
76
82
|
assert count > 0, 'no thumbnails found'
|
77
83
|
end
|
78
|
-
end
|
84
|
+
end
|
data/tests/test_helper.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
#
|
3
|
-
# Copyright (c) 2006, 2007 - R.W. van 't Veer
|
3
|
+
# Copyright (c) 2006, 2007, 2008 - R.W. van 't Veer
|
4
4
|
|
5
5
|
require 'test/unit'
|
6
6
|
require 'stringio'
|
@@ -36,4 +36,4 @@ class Hash
|
|
36
36
|
def to_s
|
37
37
|
keys.map{|k| k.to_s}.sort.map{|k| "#{k.inspect} => #{self[k].inspect}" }.join(', ')
|
38
38
|
end
|
39
|
-
end
|
39
|
+
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
#
|
3
|
-
# Copyright (c) 2006, 2007 - R.W. van 't Veer
|
3
|
+
# Copyright (c) 2006, 2007, 2008 - R.W. van 't Veer
|
4
4
|
|
5
5
|
require File.join(File.dirname(__FILE__), 'test_helper')
|
6
6
|
|
7
|
-
class
|
8
|
-
def setup
|
7
|
+
class TIFFTest < Test::Unit::TestCase
|
8
|
+
def setup
|
9
9
|
@t = TIFF.new(f('nikon_d1x.tif'))
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def test_initialize
|
13
13
|
all_test_tiffs.each do |fname|
|
14
14
|
assert_nothing_raised do
|
@@ -22,11 +22,11 @@ class TestTIFF < Test::Unit::TestCase
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
def test_multiple_images
|
27
27
|
assert_equal 2, @t.size
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
def test_size
|
31
31
|
assert_equal 269, @t.image_width
|
32
32
|
assert_equal 269, @t.image_length
|
@@ -36,29 +36,29 @@ class TestTIFF < Test::Unit::TestCase
|
|
36
36
|
assert_equal 160, @t[1].image_length
|
37
37
|
assert_equal 120, @t[1].width
|
38
38
|
assert_equal 160, @t[1].height
|
39
|
-
|
39
|
+
|
40
40
|
@t = TIFF.new(f('plain.tif'))
|
41
41
|
assert_equal 23, @t.image_width
|
42
42
|
assert_equal 24, @t.image_length
|
43
43
|
assert_equal 23, @t.width
|
44
44
|
assert_equal 24, @t.height
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
def test_enumerable
|
48
48
|
assert_equal @t[1], @t.find { |i| i.f_number.nil? }
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
def test_misc_fields
|
52
52
|
assert_equal 'Canon PowerShot G3', TIFF.new(f('canon-g3.exif')).model
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
def test_dates
|
56
56
|
(all_test_tiffs - [f('weird_date.exif'), f('plain.tif'), f('endless-loop.exif')]).each do |fname|
|
57
57
|
assert_kind_of Time, TIFF.new(fname).date_time
|
58
58
|
end
|
59
59
|
assert_nil TIFF.new(f('weird_date.exif')).date_time
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
def test_orientation
|
63
63
|
tested = 0 # count tests because not all exif samples have an orientation field
|
64
64
|
all_test_exifs.each do |fname|
|
@@ -81,7 +81,7 @@ class TestTIFF < Test::Unit::TestCase
|
|
81
81
|
end
|
82
82
|
assert tested > 0
|
83
83
|
end
|
84
|
-
|
84
|
+
|
85
85
|
def test_gps
|
86
86
|
t = TIFF.new(f('gps.exif'))
|
87
87
|
assert_equal "\2\2\0\0", t.gps_version_id
|
@@ -90,19 +90,24 @@ class TestTIFF < Test::Unit::TestCase
|
|
90
90
|
assert_equal [5355537.quo(100000), 0.quo(1), 0.quo(1)], t.gps_latitude
|
91
91
|
assert_equal [678886.quo(100000), 0.quo(1), 0.quo(1)], t.gps_longitude
|
92
92
|
assert_equal 'WGS84', t.gps_map_datum
|
93
|
-
|
93
|
+
|
94
94
|
(all_test_exifs - [f('gps.exif')]).each do |fname|
|
95
95
|
assert_nil TIFF.new(fname).gps_version_id
|
96
96
|
end
|
97
97
|
end
|
98
|
-
|
98
|
+
|
99
99
|
def test_ifd_dispatch
|
100
|
+
assert @t.respond_to?(:f_number)
|
101
|
+
assert @t.respond_to?('f_number')
|
102
|
+
assert @t.methods.include?('f_number')
|
103
|
+
assert TIFF.instance_methods.include?('f_number')
|
104
|
+
|
100
105
|
assert_not_nil @t.f_number
|
101
106
|
assert_kind_of Rational, @t.f_number
|
102
107
|
assert_not_nil @t[0].f_number
|
103
108
|
assert_kind_of Rational, @t[0].f_number
|
104
109
|
end
|
105
|
-
|
110
|
+
|
106
111
|
def test_avoid_dispatch_to_nonexistent_ifds
|
107
112
|
assert_nothing_raised do
|
108
113
|
all_test_tiffs.each do |fname|
|
@@ -111,32 +116,32 @@ class TestTIFF < Test::Unit::TestCase
|
|
111
116
|
end
|
112
117
|
end
|
113
118
|
end
|
114
|
-
|
119
|
+
|
115
120
|
def test_to_hash
|
116
121
|
all_test_tiffs.each do |fname|
|
117
122
|
t = TIFF.new(fname)
|
118
123
|
TIFF::TAGS.each do |key|
|
119
|
-
assert_literally_equal t.send(key), t.to_hash[key], "#{key} not equal"
|
124
|
+
assert_literally_equal t.send(key), t.to_hash[key.to_sym], "#{key} not equal"
|
120
125
|
end
|
121
126
|
end
|
122
127
|
end
|
123
|
-
|
128
|
+
|
124
129
|
def test_old_style
|
125
130
|
assert_nothing_raised do
|
126
131
|
assert_not_nil @t[:f_number]
|
127
132
|
end
|
128
133
|
end
|
129
|
-
|
134
|
+
|
130
135
|
def test_yaml_dump_and_load
|
131
136
|
require 'yaml'
|
132
|
-
|
137
|
+
|
133
138
|
all_test_tiffs.each do |fname|
|
134
139
|
t = TIFF.new(fname)
|
135
140
|
y = YAML.dump(t)
|
136
141
|
assert_literally_equal t.to_hash, YAML.load(y).to_hash
|
137
142
|
end
|
138
143
|
end
|
139
|
-
|
144
|
+
|
140
145
|
def test_jpeg_thumbnails
|
141
146
|
count = 0
|
142
147
|
all_test_tiffs.each do |fname|
|
@@ -152,9 +157,9 @@ class TestTIFF < Test::Unit::TestCase
|
|
152
157
|
end
|
153
158
|
assert count > 0, 'no thumbnails found'
|
154
159
|
end
|
155
|
-
|
160
|
+
|
156
161
|
def test_should_not_loop_endlessly
|
157
162
|
TIFF.new(f('endless-loop.exif'))
|
158
163
|
assert true
|
159
164
|
end
|
160
|
-
end
|
165
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exifr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- R.W. van 't Veer
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-10-15 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -20,7 +20,7 @@ executables:
|
|
20
20
|
extensions: []
|
21
21
|
|
22
22
|
extra_rdoc_files:
|
23
|
-
- README
|
23
|
+
- README.rdoc
|
24
24
|
- CHANGELOG
|
25
25
|
files:
|
26
26
|
- Rakefile
|
@@ -28,10 +28,6 @@ files:
|
|
28
28
|
- lib/exifr.rb
|
29
29
|
- lib/jpeg.rb
|
30
30
|
- lib/tiff.rb
|
31
|
-
- tests/data
|
32
|
-
- tests/test_helper.rb
|
33
|
-
- tests/test_jpeg.rb
|
34
|
-
- tests/test_tiff.rb
|
35
31
|
- tests/data/1x1.jpg
|
36
32
|
- tests/data/apple-aperture-1.5.exif
|
37
33
|
- tests/data/canon-g3.exif
|
@@ -48,13 +44,19 @@ files:
|
|
48
44
|
- tests/data/plain.tif
|
49
45
|
- tests/data/Trust-DC3500_MINI.exif
|
50
46
|
- tests/data/weird_date.exif
|
51
|
-
-
|
47
|
+
- tests/test_helper.rb
|
48
|
+
- tests/jpeg_test.rb
|
49
|
+
- tests/tiff_test.rb
|
50
|
+
- README.rdoc
|
52
51
|
- CHANGELOG
|
53
52
|
has_rdoc: true
|
54
|
-
homepage: http://
|
53
|
+
homepage: http://github.com/remvee/exifr/
|
55
54
|
post_install_message:
|
56
|
-
rdoc_options:
|
57
|
-
|
55
|
+
rdoc_options:
|
56
|
+
- --title
|
57
|
+
- EXIF Reader for Ruby API Documentation
|
58
|
+
- --main
|
59
|
+
- README.rdoc
|
58
60
|
require_paths:
|
59
61
|
- lib
|
60
62
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -72,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
74
|
requirements: []
|
73
75
|
|
74
76
|
rubyforge_project:
|
75
|
-
rubygems_version: 1.0
|
77
|
+
rubygems_version: 1.2.0
|
76
78
|
signing_key:
|
77
79
|
specification_version: 2
|
78
80
|
summary: EXIF Reader is a module to read EXIF from JPEG images.
|