File tree 2 files changed +5
-9
lines changed
2 files changed +5
-9
lines changed Original file line number Diff line number Diff line change @@ -83,21 +83,17 @@ def probe(stream):
83
83
w , h = struct .unpack ('<HH' , chunk [6 :10 ])
84
84
return {'type' : 'gif' , 'width' : w , 'height' : h }
85
85
elif chunk .startswith (b'\xff \xd8 ' ):
86
- start = 0
86
+ start = 2
87
87
data = chunk
88
88
while True :
89
- chunk = stream .read (10 )
90
- if not chunk :
89
+ if data [start :start + 1 ] != b'\xff ' :
91
90
return
92
- data += chunk
93
- next = data .find (b'\xff ' , start + 1 )
94
- if next == - 1 :
95
- continue
96
- start = next
97
- data += stream .read (10 )
98
91
if data [start + 1 ] in b'\xc0 \xc2 ' :
99
92
h , w = struct .unpack ('>HH' , data [start + 5 :start + 9 ])
100
93
return {'type' : 'jpg' , 'width' : w , 'height' : h }
94
+ segment_size , = struct .unpack ('>H' , data [start + 2 :start + 4 ])
95
+ data += stream .read (segment_size + 9 )
96
+ start = start + segment_size + 2
101
97
elif chunk .startswith (b'\x00 \x00 \x01 \x00 ' ) or chunk .startswith (b'\x00 \x00 \x02 \x00 ' ):
102
98
img_type = 'ico' if chunk [2 :3 ] == b'\x01 ' else 'cur'
103
99
num_images = struct .unpack ('<H' , chunk [4 :6 ])[0 ]
You can’t perform that action at this time.
0 commit comments