Paper Office
paper-pptxAPI referenceparts.image

Image

paper-pptx 0.2.0 API reference

Immutable value object representing an image such as a JPEG, PNG, or GIF.

Image(blob: bytes, filename: str | None)

Attributes

blob

attributeblobbytes

The binary image bytestream of this image.

content_type

attributecontent_typestr

MIME-type of this image, e.g. "image/jpeg".

dpi

attributedpituple[int, int]

A (horz_dpi, vert_dpi) 2-tuple specifying the dots-per-inch resolution of this image.

A default value of (72, 72) is used if the dpi is not specified in the image file.

ext

attributeextstr

Canonical file extension for this image e.g. 'png'.

The returned extension is all lowercase and is the canonical extension for the content type of this image, regardless of what extension may have been used in its filename, if any.

filename

attributefilenamestr | None

Filename from path used to load this image, if loaded from the filesystem.

None if no filename was used in loading, such as when loaded from an in-memory stream.

sha1

attributesha1str

SHA1 hash digest of the image blob.

size

attributesizetuple[int, int]

A (width, height) 2-tuple specifying the dimensions of this image in pixels.

Functions

from_blob

funcfrom_blob(blob: bytes, filename: str | None = None) -> Image

Return a new Image object loaded from the image binary in blob.

paramblobbytes
paramfilenamestr | None
= None

Returns

pptx.parts.image.Image

from_file

funcfrom_file(image_file: str | IO[bytes]) -> Image

Return a new Image object loaded from image_file.

image_file can be either a path (str) or a file-like object.

paramimage_filestr | IO[bytes]

Returns

pptx.parts.image.Image

On this page