Skip to content

gif

gif

Gif

Gif(
    px_width: int,
    px_height: int,
    horz_dpi: int,
    vert_dpi: int,
    orientation: int = 1,
)

Bases: BaseImageHeader

Image header parser for GIF images.

Note that the GIF format does not support resolution (DPI) information. Both horizontal and vertical DPI default to 72.

Source code in src/docx/image/image.py
def __init__(
    self,
    px_width: int,
    px_height: int,
    horz_dpi: int,
    vert_dpi: int,
    orientation: int = 1,
):
    self._px_width = px_width
    self._px_height = px_height
    self._horz_dpi = horz_dpi
    self._vert_dpi = vert_dpi
    self._orientation = orientation

content_type property

content_type

MIME content type for this image, unconditionally image/gif for GIF images.

default_ext property

default_ext

Default filename extension, always 'gif' for GIF images.

from_stream classmethod

from_stream(stream)

Return Gif instance having header properties parsed from GIF image in stream.

Source code in src/docx/image/gif.py
@classmethod
def from_stream(cls, stream):
    """Return |Gif| instance having header properties parsed from GIF image in
    `stream`."""
    px_width, px_height = cls._dimensions_from_stream(stream)
    return cls(px_width, px_height, 72, 72)