mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-30 01:52:18 +00:00
refactor(images): keep format limits with the module constants
This commit is contained in:
parent
e9b603f77a
commit
384c7558b2
1 changed files with 7 additions and 8 deletions
|
|
@ -11,6 +11,13 @@ from litellm.types.llms.openai import FileTypes
|
|||
|
||||
_HEADER_READ_SIZE: Final = 32
|
||||
|
||||
_JPEG_SOF_MARKERS: Final = frozenset(range(0xC0, 0xD0)) - {0xC4, 0xC8, 0xCC}
|
||||
_JPEG_MAX_SEGMENTS: Final = 1024
|
||||
_JPEG_MAX_HEADER_OFFSET: Final = 16 * 1024 * 1024
|
||||
_JPEG_FIRST_SEGMENT_OFFSET: Final = 2
|
||||
_JPEG_SOF_PAYLOAD_SIZE: Final = 5
|
||||
_JPEG_FILL_CHUNK: Final = 64 * 1024
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class ImageDimensions:
|
||||
|
|
@ -117,14 +124,6 @@ def _webp_dimensions(head: bytes) -> ImageDimensions | None:
|
|||
return None
|
||||
|
||||
|
||||
_JPEG_SOF_MARKERS: Final = frozenset(range(0xC0, 0xD0)) - {0xC4, 0xC8, 0xCC}
|
||||
_JPEG_MAX_SEGMENTS: Final = 1024
|
||||
_JPEG_MAX_HEADER_OFFSET: Final = 16 * 1024 * 1024
|
||||
_JPEG_FIRST_SEGMENT_OFFSET: Final = 2
|
||||
_JPEG_SOF_PAYLOAD_SIZE: Final = 5
|
||||
_JPEG_FILL_CHUNK: Final = 64 * 1024
|
||||
|
||||
|
||||
def _jpeg_fill_run(stream: IO[bytes], start: int, offset: int) -> int:
|
||||
stream.seek(start + offset)
|
||||
fill: Final = stream.read(_JPEG_FILL_CHUNK)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue