import struct def split(data): if data[0:4] != b"RIFF" or data[8:12] != b"WEBP": raise ValueError("Not WebP") webp_length_bytes = data[4:8] webp_length = struct.unpack("> 5-1 & ord(b"\x01") contains = 1 * flag return contains def _get_size_from_vp8L(chunk): b1 = chunk["data"][1:2] b2 = chunk["data"][2:3] b3 = chunk["data"][3:4] b4 = chunk["data"][4:5] width_minus_one = (ord(b2) & ord(b"\x3F")) << 8 | ord(b1) width = width_minus_one + 1 height_minus_one = (ord(b4) & ord(b"\x0F")) << 10 | ord(b3) << 2 | (ord(b2) & ord(b"\xC0")) >> 6 height = height_minus_one + 1 return (width, height) def _get_size_from_anmf(chunk): width_minus_one_bytes = chunk["data"][6:9] + b"\x00" width_minus_one = struct.unpack("