diff --git a/filetype/types/image.py b/filetype/types/image.py index 783aa7b..f814234 100644 --- a/filetype/types/image.py +++ b/filetype/types/image.py @@ -95,8 +95,14 @@ def __init__(self): def match(self, buf): if (len(buf) > 8 and - buf[:8] == bytearray([0x89, 0x50, 0x4e, 0x47, - 0x0d, 0x0a, 0x1a, 0x0a])): + buf[0] == 0x89 and + buf[1] == 0x50 and + buf[2] == 0x4E and + buf[3] == 0x47 and + buf[4] == 0x0D and + buf[5] == 0x0A and + buf[6] == 0x1A and + buf[7] == 0x0A): # cursor in buf, skip already readed 8 bytes i = 8 while len(buf) > i: @@ -133,12 +139,15 @@ def __init__(self): ) def match(self, buf): - return (len(buf) > 3 and + return (len(buf) > 8 and buf[0] == 0x89 and buf[1] == 0x50 and buf[2] == 0x4E and - buf[3] == 0x47) - + buf[3] == 0x47 and + buf[4] == 0x0D and + buf[5] == 0x0A and + buf[6] == 0x1A and + buf[7] == 0x0A) class Gif(Type): """