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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97fa3270a4d14398a02e6bd725753980ae12b74c2f0a6e3c160b840c59c7febf
4
- data.tar.gz: ec8ed547c94ad6dd83c0a07bb78530408d48637b18edfeb68dcb157a55c5c618
3
+ metadata.gz: e6dc62b83679b17b8dae3f44910af4e9d1d2cfcc4e22cc4687df5f59c7eb6151
4
+ data.tar.gz: 7bd89d4a659431358c4e9bba56ff133466d0408da665b509b913be5a7960ce2c
5
5
  SHA512:
6
- metadata.gz: 3d10126d25f29634c46c8b5dce11ebd9dbc373c02fc892a74cdb8cbf6aa3cef8086e2a6be2eaac2a65bc83fa64a6f517617e22dc47bc4ea56db631b678a3ee3a
7
- data.tar.gz: b98ee638dc85ab51c1f86d5b9c34c417047a79d2abb920ee8a13e7decfaf8b66fb484d7d804461de276a3f87fd40f5e30c1a420e3b25e46db51e801f77acc9c3
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
- @jpeg_thumbnails = @ifds.map do |v|
387
- if v.jpeg_interchange_format && v.jpeg_interchange_format_length
388
- start, length = v.jpeg_interchange_format, v.jpeg_interchange_format_length
389
- if Integer === start && Integer === length
390
- data[start..(start + length)]
391
- else
392
- EXIFR.logger.warn("Non numeric JpegInterchangeFormat data")
393
- nil
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
- end.compact
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.3.10
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: 2022-10-02 00:00:00.000000000 Z
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://github.com/remvee/exifr/
84
+ homepage: http://codeberg.org/rwv/exifr/
85
85
  licenses:
86
86
  - MIT
87
87
  metadata:
88
- bug_tracker_uri: https://github.com/remvee/exifr/issues
89
- changelog_uri: https://github.com/remvee/exifr/blob/master/CHANGELOG
90
- documentation_uri: https://remvee.github.io/exifr/api/
91
- homepage_uri: https://remvee.github.io/exifr/
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: 1.8.7
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.3.7
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