get_image_metadata#
- torchcodec.decoders.get_image_metadata(source: str | Path | bytes | Tensor) ImageMetadata[source]#
Get the metadata of an encoded image, without decoding it.
The format is detected from the encoded data, like in
decode_image().See
ImageMetadatafor the returned attributes, which all describe the output of the decoders.Example
from torchcodec.decoders import get_image_metadata metadata = get_image_metadata("image.jpg") print(metadata.width, metadata.height)
- Parameters:
source (str,
pathlib.Path, bytes, ortorch.Tensor) – The encoded image data: a path (strorpathlib.Path), abytesobject, or a 1-D uint8torch.Tensorof the raw encoded bytes.- Returns:
The image metadata.
- Return type:
Examples using
get_image_metadata: