exifr 1.3.8 → 1.3.10
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.
- checksums.yaml +4 -4
- data/lib/exifr/tiff.rb +21 -14
- data/tests/data/bad_gps.exif +0 -0
- data/tests/data/ios-mspix-milliseconds.jpg +0 -0
- data/tests/data/truncated.exif +0 -0
- data/tests/tiff_test.rb +14 -1
- metadata +6 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 97fa3270a4d14398a02e6bd725753980ae12b74c2f0a6e3c160b840c59c7febf
|
|
4
|
+
data.tar.gz: ec8ed547c94ad6dd83c0a07bb78530408d48637b18edfeb68dcb157a55c5c618
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3d10126d25f29634c46c8b5dce11ebd9dbc373c02fc892a74cdb8cbf6aa3cef8086e2a6be2eaac2a65bc83fa64a6f517617e22dc47bc4ea56db631b678a3ee3a
|
|
7
|
+
data.tar.gz: b98ee638dc85ab51c1f86d5b9c34c417047a79d2abb920ee8a13e7decfaf8b66fb484d7d804461de276a3f87fd40f5e30c1a420e3b25e46db51e801f77acc9c3
|
data/lib/exifr/tiff.rb
CHANGED
|
@@ -331,7 +331,9 @@ module EXIFR
|
|
|
331
331
|
|
|
332
332
|
class Degrees < Array
|
|
333
333
|
def initialize(arr)
|
|
334
|
-
|
|
334
|
+
unless arr.length == 3 && arr.all?{|v| Rational === v}
|
|
335
|
+
raise "expected [degrees, minutes, seconds]; got #{arr.inspect}"
|
|
336
|
+
end
|
|
335
337
|
super
|
|
336
338
|
end
|
|
337
339
|
|
|
@@ -480,10 +482,10 @@ module EXIFR
|
|
|
480
482
|
end
|
|
481
483
|
|
|
482
484
|
class IFD # :nodoc:
|
|
483
|
-
attr_reader :type, :fields, :offset
|
|
485
|
+
attr_reader :type, :raw_fields, :fields, :offset
|
|
484
486
|
|
|
485
487
|
def initialize(data, offset = nil, type = :image)
|
|
486
|
-
@data, @offset, @type, @fields = data, offset, type, {}
|
|
488
|
+
@data, @offset, @type, @raw_fields, @fields = data, offset, type, {}, {}
|
|
487
489
|
|
|
488
490
|
pos = offset || @data.readlong(4)
|
|
489
491
|
num = @data.readshort(pos)
|
|
@@ -544,15 +546,16 @@ module EXIFR
|
|
|
544
546
|
|
|
545
547
|
private
|
|
546
548
|
def add_field(field)
|
|
547
|
-
return
|
|
548
|
-
|
|
549
|
+
return if @raw_fields.include?(field.tag) # first encountered value wins
|
|
550
|
+
@raw_fields[field.tag] = field.value
|
|
549
551
|
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
552
|
+
return unless tag = TAG_MAPPING[@type][field.tag]
|
|
553
|
+
@fields[tag] = if IFD_TAGS.include?(tag)
|
|
554
|
+
IFD.new(@data, field.offset, tag)
|
|
555
|
+
else
|
|
556
|
+
value = ADAPTERS[tag][field.value]
|
|
557
|
+
value.kind_of?(Array) && value.size == 1 ? value.first : value
|
|
558
|
+
end
|
|
556
559
|
end
|
|
557
560
|
end
|
|
558
561
|
|
|
@@ -602,6 +605,10 @@ module EXIFR
|
|
|
602
605
|
end
|
|
603
606
|
rationals
|
|
604
607
|
end
|
|
608
|
+
when 11 # float
|
|
609
|
+
len, pack = count * 4, proc { |d| d.unpack(data.float + '*') }
|
|
610
|
+
when 12 # double
|
|
611
|
+
len, pack = count * 8, proc { |d| d.unpack(data.double + '*') }
|
|
605
612
|
else
|
|
606
613
|
return
|
|
607
614
|
end
|
|
@@ -636,7 +643,7 @@ module EXIFR
|
|
|
636
643
|
end
|
|
637
644
|
|
|
638
645
|
class Data #:nodoc:
|
|
639
|
-
attr_reader :short, :long, :file
|
|
646
|
+
attr_reader :short, :long, :float, :double, :file
|
|
640
647
|
|
|
641
648
|
def initialize(file)
|
|
642
649
|
@io = file.respond_to?(:read) ? file : (@file = File.open(file, 'rb'))
|
|
@@ -644,8 +651,8 @@ module EXIFR
|
|
|
644
651
|
@pos = 0
|
|
645
652
|
|
|
646
653
|
case self[0..1]
|
|
647
|
-
when 'II'; @short, @long = 'v', 'V'
|
|
648
|
-
when 'MM'; @short, @long = 'n', 'N'
|
|
654
|
+
when 'II'; @short, @long, @float, @double = 'v', 'V', 'e', 'E'
|
|
655
|
+
when 'MM'; @short, @long, @float, @double = 'n', 'N', 'g', 'G'
|
|
649
656
|
else
|
|
650
657
|
raise MalformedTIFF, "no byte order information found"
|
|
651
658
|
end
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/tests/tiff_test.rb
CHANGED
|
@@ -119,6 +119,10 @@ class TIFFTest < TestCase
|
|
|
119
119
|
end
|
|
120
120
|
end
|
|
121
121
|
|
|
122
|
+
def test_bad_gps
|
|
123
|
+
assert_nil TIFF.new(f('bad_gps.exif')).gps
|
|
124
|
+
end
|
|
125
|
+
|
|
122
126
|
def test_lens_model
|
|
123
127
|
t = TIFF.new(f('sony-a7ii.exif'))
|
|
124
128
|
assert_equal('FE 16-35mm F4 ZA OSS', t.lens_model)
|
|
@@ -161,7 +165,12 @@ class TIFFTest < TestCase
|
|
|
161
165
|
all_test_tiffs.each do |fname|
|
|
162
166
|
t = TIFF.new(fname)
|
|
163
167
|
y = YAML.dump(t)
|
|
164
|
-
|
|
168
|
+
v = if YAML.respond_to?(:unsafe_load)
|
|
169
|
+
YAML.unsafe_load(y)
|
|
170
|
+
else
|
|
171
|
+
YAML.load(y)
|
|
172
|
+
end
|
|
173
|
+
assert_literally_equal t.to_hash, v.to_hash
|
|
165
174
|
end
|
|
166
175
|
end
|
|
167
176
|
|
|
@@ -211,4 +220,8 @@ class TIFFTest < TestCase
|
|
|
211
220
|
assert t.methods(true).include?(:make)
|
|
212
221
|
assert ! t.methods(false).include?(:make)
|
|
213
222
|
end
|
|
223
|
+
|
|
224
|
+
def test_unknow_field
|
|
225
|
+
assert_equal [1, 1, 1, 1], TIFF.new(f('plain.tif')).first.raw_fields[0x0153] # TIFF Tag SampleFormat
|
|
226
|
+
end
|
|
214
227
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: exifr
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.
|
|
4
|
+
version: 1.3.10
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- R.W. van 't Veer
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-10-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: test-unit
|
|
@@ -59,6 +59,7 @@ files:
|
|
|
59
59
|
- tests/data/Trust-DC3500_MINI.exif
|
|
60
60
|
- tests/data/apple-aperture-1.5.exif
|
|
61
61
|
- tests/data/bad-shutter_speed_value.exif
|
|
62
|
+
- tests/data/bad_gps.exif
|
|
62
63
|
- tests/data/canon-g3.exif
|
|
63
64
|
- tests/data/endless-loop.exif
|
|
64
65
|
- tests/data/exif.jpg
|
|
@@ -66,6 +67,7 @@ files:
|
|
|
66
67
|
- tests/data/gps-altitude.jpg
|
|
67
68
|
- tests/data/gps.exif
|
|
68
69
|
- tests/data/image.jpg
|
|
70
|
+
- tests/data/ios-mspix-milliseconds.jpg
|
|
69
71
|
- tests/data/multiple-app1.jpg
|
|
70
72
|
- tests/data/negative-exposure-bias-value.exif
|
|
71
73
|
- tests/data/nikon_d1x.tif
|
|
@@ -73,6 +75,7 @@ files:
|
|
|
73
75
|
- tests/data/plain.tif
|
|
74
76
|
- tests/data/samsung-sc-02b.jpg
|
|
75
77
|
- tests/data/sony-a7ii.exif
|
|
78
|
+
- tests/data/truncated.exif
|
|
76
79
|
- tests/data/user-comment.exif
|
|
77
80
|
- tests/data/weird_date.exif
|
|
78
81
|
- tests/jpeg_test.rb
|
|
@@ -102,8 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
102
105
|
- !ruby/object:Gem::Version
|
|
103
106
|
version: '0'
|
|
104
107
|
requirements: []
|
|
105
|
-
|
|
106
|
-
rubygems_version: 2.7.6
|
|
108
|
+
rubygems_version: 3.3.7
|
|
107
109
|
signing_key:
|
|
108
110
|
specification_version: 4
|
|
109
111
|
summary: Read EXIF from JPEG and TIFF images
|