lib/tiff.rb in remvee-exifr-0.10.6.1 vs lib/tiff.rb in remvee-exifr-0.10.7
- old
+ new
@@ -317,11 +317,14 @@
when 'MM'; data.short, data.long = 'n', 'N'
else; raise 'no II or MM marker found'
end
@ifds = [IFD.new(data)]
- while ifd = @ifds.last.next; @ifds << ifd; end
+ while ifd = @ifds.last.next
+ break if @ifds.find{|i| i.offset == ifd.offset}
+ @ifds << ifd
+ end
@jpeg_thumbnails = @ifds.map do |ifd|
if ifd.jpeg_interchange_format && ifd.jpeg_interchange_format_length
start, length = ifd.jpeg_interchange_format, ifd.jpeg_interchange_format_length
data[start..(start + length)]
@@ -386,11 +389,11 @@
def inspect # :nodoc:
@ifds.inspect
end
class IFD # :nodoc:
- attr_reader :type, :fields
+ attr_reader :type, :fields, :offset
def initialize(data, offset = nil, type = :image)
@data, @offset, @type, @fields = data, offset, type, {}
pos = offset || @data.readlong(4)
@@ -429,10 +432,10 @@
def inspect
to_hash.inspect
end
def next?
- @offset_next != 0 && @offset_next < @data.size && (@offset || 0) < @offset_next
+ @offset_next != 0 && @offset_next < @data.size
end
def next
IFD.new(@data, @offset_next) if next?
end