made bs4 and soupsieve standalone in this project
This commit is contained in:
@ -194,13 +194,19 @@ def get_image_size(fhandle, pathlike):
|
||||
fhandle.seek(size, 1)
|
||||
byte = fhandle.read(1)
|
||||
if byte == b"":
|
||||
fhandle = end
|
||||
byte = fhandle.read(1)
|
||||
|
||||
# Reached end of file unexpectedly, break the loop
|
||||
break
|
||||
while ord(byte) == 0xFF:
|
||||
byte = fhandle.read(1)
|
||||
if byte == b"": # Check EOF in inner loop too
|
||||
break
|
||||
if byte == b"": # Break outer loop if inner loop hit EOF
|
||||
break
|
||||
ftype = ord(byte)
|
||||
size = struct.unpack(">H", fhandle.read(2))[0] - 2
|
||||
# Check if the loop exited because of a break (EOF) before finding the marker
|
||||
if not (0xC0 <= ftype <= 0xCF):
|
||||
return "unknown format {!r}".format(format_)
|
||||
# We are at a SOFn block
|
||||
fhandle.seek(1, 1) # Skip `precision' byte.
|
||||
height, width = struct.unpack(">HH", fhandle.read(4))
|
||||
|
||||
Reference in New Issue
Block a user