mirror of
https://github.com/sdsykes/fastimage.git
synced 2025-08-10 00:01:04 -04:00
handle negative height bitmaps and ensure that we read in bmp dimensions as signed ints
This commit is contained in:
parent
dd396f5644
commit
606dd34690
@ -413,8 +413,17 @@ class FastImage
|
||||
end
|
||||
|
||||
def parse_size_for_bmp
|
||||
d = get_chars(29)[14..28]
|
||||
d.unpack("C")[0] == 40 ? d[4..-1].unpack('LL') : d[4..8].unpack('SS')
|
||||
d = get_chars(32)[14..28]
|
||||
header = d.unpack("C")[0]
|
||||
|
||||
result = if header == 40
|
||||
d[4..-1].unpack('l<l<')
|
||||
else
|
||||
d[4..8].unpack('SS')
|
||||
end
|
||||
|
||||
# ImageHeight is expressed in pixels. The absolute value is necessary because ImageHeight can be negative
|
||||
[result.first, result.last.abs]
|
||||
end
|
||||
|
||||
def get_exif_byte_order
|
||||
|
BIN
test/fixtures/test2.bmp
vendored
Normal file
BIN
test/fixtures/test2.bmp
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
@ -12,6 +12,7 @@ FixturePath = File.join(PathHere, "fixtures")
|
||||
|
||||
GoodFixtures = {
|
||||
"test.bmp"=>[:bmp, [40, 27]],
|
||||
"test2.bmp"=>[:bmp, [1920, 1080]],
|
||||
"test.gif"=>[:gif, [17, 32]],
|
||||
"test.jpg"=>[:jpeg, [882, 470]],
|
||||
"test.png"=>[:png, [30, 20]],
|
||||
|
Loading…
x
Reference in New Issue
Block a user