Skip to main content
# gif2numpy Version 1.3
Python library to convert single oder multiple frame gif images to numpy images or to OpenCV without PIL or pillow. OpenCV does not support gif images.

Install it with

setup.py install

or with

pip install gif2numpy

# Usage

You can use the library this way:

from __future__ import print_function
import gif2numpy
import cv2

images = "Images/Rotating_earth.gif", "Images/hopper.gif", "Images/audrey.gif", "Images/testcolors.gif"
for image in images:
frames, exts, image_specs = gif2numpy.convert(image)
print()
print("Image:", image)
print()
print("len frames", len(frames))
print("len exts", len(exts))
print("exts:", exts)
print("image_specs:", image_specs)
for i in range(len(frames)):
cv2.imshow("np_image", frames[i])
k = cv2.waitKey(0)
if k == 27:
break
cv2.destroyWindow("np_image")

There is also the class Gif inside the module which can be used to determine Gif features inside the image.
The general features are given in the dictionary image_specs.
If multiple frames are saved in the gif you can retrieve them in the list of frames. The list of exts with the same index number as in frames gives you the specifications of each frame (block_size, flags, delay_time, transparent_idx, terminator, lzw_min,
top, left, width, height, has_color_table, local_color_table).

By default this module was designed for the connection with cv2 which has the BGR(A) color mapping sequence for the color tuples. In case you are not using opencv and its color mapping you should set the color conversion flag BGR2RGB to False so that no color conversion takes place. So use the module like that:

from __future__ import print_function
import gif2numpy
import cv2

images = "Images/Rotating_earth.gif", "Images/hopper.gif", "Images/audrey.gif", "Images/testcolors.gif"
for image in images:
frames, exts, image_specs = gif2numpy.convert(image, BGR2RGB=False)
print()
print("Image:", image)
print()
print("len frames", len(frames))
print("len exts", len(exts))
print("exts:", exts)
print("image_specs:", image_specs)
for i in range(len(frames)):
cv2.imshow("np_image", frames[i])
k = cv2.waitKey(0)
if k == 27:
break
cv2.destroyWindow("np_image")

# Version history

1.3: Additional flag for BGR2RGB conversion, by default this flag is set and a BGR2RGB color conversion takes place, better time optimization of color table mapping

1.2: Bug fix for multiple frame gif images, pixel error in frames fixed

1.1: single frame and multiple frame gif images are now supported

1.0: first release just for still single images

# Dependencies

You need to install numpy and kaitaistruct by:

pip install numpy kaitaistruct

Metadata

Release files for gif2numpy 1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gif2numpy 1.3
File Size Uploaded Provenance Actions
gif2numpy-1.3.zip 10.0 kB Without provenance Details for gif2numpy-1.3.zip

Release files / gif2numpy-1.3.zip

Download URL gif2numpy-1.3.zip
Size 10.0 kB
Tags Source
SHA-256 checksum
How to use checksums
597d9f03c0263fff6a0ba9b2ff688c8a0e4d2f888b861ce10987251020a9b544
BLAKE2b-256 checksum
How to use checksums
e6e7beab1c356898b1d7318d3f245d38df0d35c3cb7eb45ff5904b1bcaca5097
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.12

Security for gif2numpy 1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page