mirror of
https://github.com/sdsykes/fastimage.git
synced 2025-11-13 00:01:26 -05:00
Improve parse_type UnknownImageType detection
In case of 'ice' file type when neither 1 or 2 is found it should raise ```UnknownImageType``` but it didn't, probably due to the method not being 100% DRY. This commit fixes both issues at once
This commit is contained in:
parent
c99b127d1b
commit
13b0244968
@ -442,7 +442,7 @@ class FastImage
|
|||||||
end
|
end
|
||||||
|
|
||||||
def parse_type
|
def parse_type
|
||||||
case @stream.peek(2)
|
parsed_type = case @stream.peek(2)
|
||||||
when "BM"
|
when "BM"
|
||||||
:bmp
|
:bmp
|
||||||
when "GI"
|
when "GI"
|
||||||
@ -462,22 +462,14 @@ class FastImage
|
|||||||
when 2 then :cur
|
when 2 then :cur
|
||||||
end
|
end
|
||||||
when "RI"
|
when "RI"
|
||||||
if @stream.peek(12)[8..11] == "WEBP"
|
:webp if @stream.peek(12)[8..11] == "WEBP"
|
||||||
:webp
|
|
||||||
else
|
|
||||||
raise UnknownImageType
|
|
||||||
end
|
|
||||||
when "<s"
|
when "<s"
|
||||||
:svg
|
:svg
|
||||||
when "<?"
|
when "<?"
|
||||||
if @stream.peek(100).include?("<svg")
|
:svg if @stream.peek(100).include?("<svg")
|
||||||
:svg
|
|
||||||
else
|
|
||||||
raise UnknownImageType
|
|
||||||
end
|
|
||||||
else
|
|
||||||
raise UnknownImageType
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
parsed_type or raise UnknownImageType
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_size_for_ico
|
def parse_size_for_ico
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user