exifr 1.0.4 → 1.0.5
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 +3 -0
- data/README.rdoc +4 -0
- data/lib/exifr/tiff.rb +25 -18
- metadata +4 -4
data/CHANGELOG
CHANGED
data/README.rdoc
CHANGED
@@ -17,6 +17,10 @@ EXIF Reader is a module to read metadata from JPEG and TIFF images.
|
|
17
17
|
EXIFR::TIFF.new('DSC_0218.TIF').exposure_time.to_s # => "1/100"
|
18
18
|
EXIFR::TIFF.new('DSC_0218.TIF').f_number.to_f # => 5.0
|
19
19
|
|
20
|
+
== XMP data access
|
21
|
+
If you need to access XMP data you can use the xmp gem. More info and
|
22
|
+
examples at https://github.com/amberbit/xmp
|
23
|
+
|
20
24
|
== Author
|
21
25
|
R.W. van 't Veer
|
22
26
|
|
data/lib/exifr/tiff.rb
CHANGED
@@ -311,20 +311,20 @@ module EXIFR
|
|
311
311
|
|
312
312
|
# +file+ is a filename or an IO object. Hint: use StringIO when working with slurped data like blobs.
|
313
313
|
def initialize(file)
|
314
|
-
|
314
|
+
Data.open(file) do |data|
|
315
|
+
@ifds = [IFD.new(data)]
|
316
|
+
while ifd = @ifds.last.next
|
317
|
+
break if @ifds.find{|i| i.offset == ifd.offset}
|
318
|
+
@ifds << ifd
|
319
|
+
end
|
315
320
|
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
321
|
+
@jpeg_thumbnails = @ifds.map do |ifd|
|
322
|
+
if ifd.jpeg_interchange_format && ifd.jpeg_interchange_format_length
|
323
|
+
start, length = ifd.jpeg_interchange_format, ifd.jpeg_interchange_format_length
|
324
|
+
data[start..(start + length)]
|
325
|
+
end
|
326
|
+
end.compact
|
320
327
|
end
|
321
|
-
|
322
|
-
@jpeg_thumbnails = @ifds.map do |ifd|
|
323
|
-
if ifd.jpeg_interchange_format && ifd.jpeg_interchange_format_length
|
324
|
-
start, length = ifd.jpeg_interchange_format, ifd.jpeg_interchange_format_length
|
325
|
-
data[start..(start + length)]
|
326
|
-
end
|
327
|
-
end.compact
|
328
328
|
end
|
329
329
|
|
330
330
|
# Number of images.
|
@@ -531,10 +531,10 @@ module EXIFR
|
|
531
531
|
end
|
532
532
|
|
533
533
|
class Data #:nodoc:
|
534
|
-
attr_reader :short, :long
|
534
|
+
attr_reader :short, :long, :file
|
535
535
|
|
536
536
|
def initialize(file)
|
537
|
-
@
|
537
|
+
@io = file.respond_to?(:read) ? file : (@file = File.open(file, 'rb'))
|
538
538
|
@buffer = ''
|
539
539
|
@pos = 0
|
540
540
|
|
@@ -546,6 +546,13 @@ module EXIFR
|
|
546
546
|
end
|
547
547
|
end
|
548
548
|
|
549
|
+
def self.open(file, &block)
|
550
|
+
data = new(file)
|
551
|
+
yield data
|
552
|
+
ensure
|
553
|
+
data && data.file && data.file.close
|
554
|
+
end
|
555
|
+
|
549
556
|
def [](pos)
|
550
557
|
unless pos.respond_to?(:begin) && pos.respond_to?(:end)
|
551
558
|
pos = pos..pos
|
@@ -567,14 +574,14 @@ module EXIFR
|
|
567
574
|
end
|
568
575
|
|
569
576
|
def size
|
570
|
-
@
|
571
|
-
@
|
577
|
+
@io.seek(0, IO::SEEK_END)
|
578
|
+
@io.pos
|
572
579
|
end
|
573
580
|
|
574
581
|
private
|
575
582
|
def read_for(pos)
|
576
|
-
@
|
577
|
-
@buffer = @
|
583
|
+
@io.seek(@pos = pos.begin)
|
584
|
+
@buffer = @io.read([pos.end - pos.begin, 4096].max)
|
578
585
|
end
|
579
586
|
end
|
580
587
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exifr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 5
|
10
|
+
version: 1.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- R.W. van 't Veer
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-03-24 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|