exifr 1.3.10 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/exifr/jpeg.rb +5 -5
- data/lib/exifr/tiff.rb +15 -11
- data/tests/jpeg_test.rb +7 -0
- data/tests/tiff_test.rb +7 -0
- metadata +9 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6dc62b83679b17b8dae3f44910af4e9d1d2cfcc4e22cc4687df5f59c7eb6151
|
4
|
+
data.tar.gz: 7bd89d4a659431358c4e9bba56ff133466d0408da665b509b913be5a7960ce2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fd9a7202ad01ea9b143d1a74aa97b1cb1e5cb649aa28b5bb6ae8c23f0982d19cbe4977b07f2f71a2ea9204554080d68d3e467acc25c375de23c9c1a12d0e85f
|
7
|
+
data.tar.gz: a00a1df2810fea82a32835998b1e249c99c40b92e4995bbed706a742536c408efe91935786c458dbb0ed7ba30de08cc6bcc73d6a274b850aff418d80df6b2747
|
data/lib/exifr/jpeg.rb
CHANGED
@@ -29,11 +29,11 @@ module EXIFR
|
|
29
29
|
attr_reader :app1s
|
30
30
|
|
31
31
|
# +file+ is a filename or an IO object. Hint: use StringIO when working with slurped data like blobs.
|
32
|
-
def initialize(file)
|
32
|
+
def initialize(file, load_thumbnails: true)
|
33
33
|
if file.kind_of? String
|
34
|
-
File.open(file, 'rb') { |io| examine(io) }
|
34
|
+
File.open(file, 'rb') { |io| examine(io, load_thumbnails: load_thumbnails) }
|
35
35
|
else
|
36
|
-
examine(file.dup)
|
36
|
+
examine(file.dup, load_thumbnails: load_thumbnails)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -95,7 +95,7 @@ module EXIFR
|
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
-
def examine(io)
|
98
|
+
def examine(io, load_thumbnails: true)
|
99
99
|
io = Reader.new(io)
|
100
100
|
|
101
101
|
unless io.getbyte == 0xFF && io.getbyte == 0xD8 # SOI
|
@@ -121,7 +121,7 @@ module EXIFR
|
|
121
121
|
|
122
122
|
if app1 = @app1s.find { |d| d[0..5] == "Exif\0\0" }
|
123
123
|
@exif_data = app1[6..-1]
|
124
|
-
@exif = TIFF.new(StringIO.new(@exif_data))
|
124
|
+
@exif = TIFF.new(StringIO.new(@exif_data), load_thumbnails: load_thumbnails)
|
125
125
|
end
|
126
126
|
end
|
127
127
|
end
|
data/lib/exifr/tiff.rb
CHANGED
@@ -375,7 +375,7 @@ module EXIFR
|
|
375
375
|
TAGS = [TAG_MAPPING.keys, TAG_MAPPING.values.map{|v|v.values}].flatten.uniq - IFD_TAGS
|
376
376
|
|
377
377
|
# +file+ is a filename or an +IO+ object. Hint: use +StringIO+ when working with slurped data like blobs.
|
378
|
-
def initialize(file)
|
378
|
+
def initialize(file, load_thumbnails: true)
|
379
379
|
Data.open(file) do |data|
|
380
380
|
@ifds = [IFD.new(data)]
|
381
381
|
while ifd = @ifds.last.next
|
@@ -383,17 +383,21 @@ module EXIFR
|
|
383
383
|
@ifds << ifd
|
384
384
|
end
|
385
385
|
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
386
|
+
if load_thumbnails
|
387
|
+
@jpeg_thumbnails = @ifds.map do |v|
|
388
|
+
if v.jpeg_interchange_format && v.jpeg_interchange_format_length
|
389
|
+
start, length = v.jpeg_interchange_format, v.jpeg_interchange_format_length
|
390
|
+
if Integer === start && Integer === length
|
391
|
+
data[start..(start + length)]
|
392
|
+
else
|
393
|
+
EXIFR.logger.warn("Non numeric JpegInterchangeFormat data")
|
394
|
+
nil
|
395
|
+
end
|
394
396
|
end
|
395
|
-
end
|
396
|
-
|
397
|
+
end.compact
|
398
|
+
else
|
399
|
+
@jpeg_thumbnails = []
|
400
|
+
end
|
397
401
|
end
|
398
402
|
end
|
399
403
|
|
data/tests/jpeg_test.rb
CHANGED
@@ -127,6 +127,13 @@ class JPEGTest < TestCase
|
|
127
127
|
assert count > 0, 'no thumbnails found'
|
128
128
|
end
|
129
129
|
|
130
|
+
def test_skippable_thumbnail
|
131
|
+
all_test_jpegs.each do |fname|
|
132
|
+
jpeg = JPEG.new(fname, load_thumbnails: false)
|
133
|
+
assert jpeg.thumbnail.nil?
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
130
137
|
def test_gps_with_altitude
|
131
138
|
t = JPEG.new(f('gps-altitude.jpg'))
|
132
139
|
|
data/tests/tiff_test.rb
CHANGED
@@ -188,6 +188,13 @@ class TIFFTest < TestCase
|
|
188
188
|
assert count > 0, 'no thumbnails found'
|
189
189
|
end
|
190
190
|
|
191
|
+
def test_skippable_jpeg_thumbnails
|
192
|
+
all_test_tiffs.each do |fname|
|
193
|
+
t = TIFF.new(fname, load_thumbnails: false)
|
194
|
+
assert t.jpeg_thumbnails.empty?
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
191
198
|
def test_should_not_loop_endlessly
|
192
199
|
TIFF.new(f('endless-loop.exif'))
|
193
200
|
assert true
|
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.
|
4
|
+
version: 1.4.1
|
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: 2025-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-unit
|
@@ -81,15 +81,14 @@ files:
|
|
81
81
|
- tests/jpeg_test.rb
|
82
82
|
- tests/test_helper.rb
|
83
83
|
- tests/tiff_test.rb
|
84
|
-
homepage: http://
|
84
|
+
homepage: http://codeberg.org/rwv/exifr/
|
85
85
|
licenses:
|
86
86
|
- MIT
|
87
87
|
metadata:
|
88
|
-
bug_tracker_uri: https://
|
89
|
-
changelog_uri: https://
|
90
|
-
documentation_uri: https://
|
91
|
-
homepage_uri: https://
|
92
|
-
source_code_uri: https://github.com/remvee/exifr
|
88
|
+
bug_tracker_uri: https://codeberg.org/rwv/exifr/issues
|
89
|
+
changelog_uri: https://codeberg.org/rwv/exifr/raw/branch/master/CHANGELOG
|
90
|
+
documentation_uri: https://www.rubydoc.info/gems/exifr
|
91
|
+
homepage_uri: https://codeberg.org/rwv/exifr
|
93
92
|
post_install_message:
|
94
93
|
rdoc_options: []
|
95
94
|
require_paths:
|
@@ -98,14 +97,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
97
|
requirements:
|
99
98
|
- - ">="
|
100
99
|
- !ruby/object:Gem::Version
|
101
|
-
version:
|
100
|
+
version: '2.0'
|
102
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
102
|
requirements:
|
104
103
|
- - ">="
|
105
104
|
- !ruby/object:Gem::Version
|
106
105
|
version: '0'
|
107
106
|
requirements: []
|
108
|
-
rubygems_version: 3.
|
107
|
+
rubygems_version: 3.5.11
|
109
108
|
signing_key:
|
110
109
|
specification_version: 4
|
111
110
|
summary: Read EXIF from JPEG and TIFF images
|