about summary refs log tree commit diff
path: root/.venv/lib/python3.12/site-packages/docx/image/gif.py
diff options
context:
space:
mode:
authorS. Solomon Darnell2025-03-28 21:52:21 -0500
committerS. Solomon Darnell2025-03-28 21:52:21 -0500
commit4a52a71956a8d46fcb7294ac71734504bb09bcc2 (patch)
treeee3dc5af3b6313e921cd920906356f5d4febc4ed /.venv/lib/python3.12/site-packages/docx/image/gif.py
parentcc961e04ba734dd72309fb548a2f97d67d578813 (diff)
downloadgn-ai-master.tar.gz
two version of R2R are here HEAD master
Diffstat (limited to '.venv/lib/python3.12/site-packages/docx/image/gif.py')
-rw-r--r--.venv/lib/python3.12/site-packages/docx/image/gif.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/.venv/lib/python3.12/site-packages/docx/image/gif.py b/.venv/lib/python3.12/site-packages/docx/image/gif.py
new file mode 100644
index 00000000..e1648726
--- /dev/null
+++ b/.venv/lib/python3.12/site-packages/docx/image/gif.py
@@ -0,0 +1,38 @@
+from struct import Struct
+
+from .constants import MIME_TYPE
+from .image import BaseImageHeader
+
+
+class Gif(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.
+    """
+
+    @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)
+
+    @property
+    def content_type(self):
+        """MIME content type for this image, unconditionally `image/gif` for GIF
+        images."""
+        return MIME_TYPE.GIF
+
+    @property
+    def default_ext(self):
+        """Default filename extension, always 'gif' for GIF images."""
+        return "gif"
+
+    @classmethod
+    def _dimensions_from_stream(cls, stream):
+        stream.seek(6)
+        bytes_ = stream.read(4)
+        struct = Struct("<HH")
+        px_width, px_height = struct.unpack(bytes_)
+        return px_width, px_height