mirror of
https://github.com/sdsykes/fastimage.git
synced 2025-12-30 00:05:02 -05:00
Merge pull request #68 from michieldewit/largest_icon
For ICO files, return the largest size (by number of pixels) rather than the size of the first icon
This commit is contained in:
commit
87cc1e7bdb
@ -463,7 +463,9 @@ class FastImage
|
||||
end
|
||||
|
||||
def parse_size_for_ico
|
||||
@stream.read(8)[6..7].unpack('CC').map{|byte| byte == 0 ? 256 : byte }
|
||||
icons = @stream.read(6)[4..5].unpack('v').first
|
||||
sizes = icons.times.map { @stream.read(16).unpack('C2').map { |x| x == 0 ? 256 : x } }.sort_by { |w,h| w * h }
|
||||
sizes.last
|
||||
end
|
||||
alias_method :parse_size_for_cur, :parse_size_for_ico
|
||||
|
||||
|
||||
BIN
test/fixtures/favicon2.ico
vendored
Normal file
BIN
test/fixtures/favicon2.ico
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.3 KiB |
@ -26,7 +26,8 @@ GoodFixtures = {
|
||||
"infinite.jpg"=>[:jpeg, [160,240]],
|
||||
"orient_2.jpg"=>[:jpeg, [230,408]],
|
||||
"favicon.ico" => [:ico, [16, 16]],
|
||||
"man.ico" => [:ico, [48, 48]],
|
||||
"favicon2.ico" => [:ico, [32, 32]],
|
||||
"man.ico" => [:ico, [256, 256]],
|
||||
"test.cur" => [:cur, [32, 32]],
|
||||
"webp_vp8x.webp" => [:webp, [386, 395]],
|
||||
"webp_vp8l.webp" => [:webp, [386, 395]],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user