Skip to content

Commit

Permalink
Handle tiff format with long dimension values, fixes #158
Browse files Browse the repository at this point in the history
  • Loading branch information
sdsykes committed Jan 2, 2025
1 parent a891d8f commit cad7175
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/fastimage/fastimage_parsing/exif.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,16 @@ def parse_exif_ifd
tag_count = @stream.read(2).unpack(@short)[0]
tag_count.downto(1) do
type = @stream.read(2).unpack(@short)[0]
@stream.read(6)
data = @stream.read(2).unpack(@short)[0]
data_type = @stream.read(2).unpack(@short)[0]
@stream.read(4)

if data_type == 4
data = @stream.read(4).unpack(@long)[0]
else
data = @stream.read(2).unpack(@short)[0]
@stream.read(2)
end

case type
when 0x0100 # image width
@width = data
Expand All @@ -43,7 +51,6 @@ def parse_exif_ifd
if @width && @height && @orientation
return # no need to parse more
end
@stream.read(2)
end
end

Expand Down
Binary file added test/fixtures/test.dng
Binary file not shown.
1 change: 1 addition & 0 deletions test/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"avif/red_green_flash.avif" => [:avif, [256, 256]],
"isobmff.jxl" => [:jxl, [1280,1600]],
"naked.jxl" => [:jxl, [1000,1000]],
"test.dng" => [:tiff, [4032, 3024]]
}

BadFixtures = [
Expand Down

0 comments on commit cad7175

Please sign in to comment.