Skip to main content

ImageFormat

ClassEnumSource

ImageFormat.png = "png"
ImageFormat.jpeg = "jpeg"
ImageFormat.webp = "webp"
ImageFormat.webp_lossless = "webp_lossless"

The image file format.

This format is only used when saving the images to files.

Enums​

NameTypeValue
pngstr"png"
jpegstr"jpeg"
webpstr"webp"
webp_losslessstr"webp_lossless"

Methods​

from_str​

v_1: Self = ImageFormat.from_str(val: str | Self)

Use a str to define this size.

Requires​

NameTypeRequired
Description
valstr | Self

Should be a file name extension without the staring dot.

For example jpg or jpeg will be converted to ImageFormat.jpeg.

Returns​

NameType
Description
v_1SelfThe converted format enum object.

from_img​

v_1: Self = ImageFormat.from_img(img: Image)

Get the appropriate image format by inferring from the image object.

Requires​

NameTypeRequired
Description
imgImageThe PIL image object used to infer the format.

Returns​

NameType
Description
v_1SelfThe converted format enum object.

as_fmt_str​

v_1: str = self.as_fmt_str()

Convert this value as the format name that can be used in pillow.

Returns​

NameType
Description
v_1strThe format name converted from this enum object.