Skip to content

vllm.multimodal.image

Functions:

_has_transparency(image)

Detect whether an image carries transparency data (RGBA, LA, PA, or tRNS chunk in P/L/RGB PNGs).

can_decode_with_torchcodec(image, data)

Whether torchcodec decodes data, opened by Pillow as image, to the same pixels as convert_image_mode(normalize_image(image), "RGB").

decode_image_torchcodec(data)

Decode data to a CHW uint8 RGB tensor, applying the EXIF orientation like normalize_image. Returns None if torchcodec fails, so the caller can fall back to Pillow: it either decodes the image (e.g. a codec left out of a source build of torchcodec) or raises the usual client error.

normalize_image(image)

Normalize EXIF orientation so the pixel data matches visual display.

open_image(fp)

Open image bytes/files with the serving format allowlist.

rescale_image_size(image, size_factor, transpose=-1)

Rescale the dimensions of an image by a constant factor.

rgba_to_rgb(image, background_color=(255, 255, 255))

Convert an RGBA image to RGB with filled background color.