Image

An image depicted in a Picture shape can be accessed using its image property. The Image object provides access to detailed properties of the image itself, including the bytes of the image file itself.

Image objects

The Image object is encountered as the image property of Picture.

class pptx.parts.image.Image[源代码]

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

property blob

The binary image bytestream of this image.

content_type[源代码]

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

dpi[源代码]

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[源代码]

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.

property filename

The filename from the path from which this image was loaded, if loaded from the filesystem. None if no filename was used in loading, such as when loaded from an in-memory stream.

sha1[源代码]

SHA1 hash digest of the image blob

size[源代码]

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