Skip to main content

Animation of random pixels converging from two colors to one color. T = 0.7 T_c. T = 0.7 T_c

Animation of random pixels converging less slowly to one color. T = 0.88 T_c. T = 0.88 T_c

Animation of random pixels staying mostly random. T = 1.06 T_c. T = 1.06 T_c

Array2GIF provides a single top-level function, write_gif(), to write a 3-D NumPy array to a GIF, or a list of these arrays to an animated GIF. It works for me - just small animations of thermodynamics simulations - like the magnetization in the Ising model shown here.

Usage

Here is an example for a 2 pixel by 3 pixel animated GIF with two frames, switching 5 frames per second. All animations from this library will loop indefinitely.

import numpy as np
from array2gif import write_gif

dataset = [
    np.array([
        [[255, 0, 0], [255, 0, 0]],  # red intensities
        [[0, 255, 0], [0, 255, 0]],  # green intensities
        [[0, 0, 255], [0, 0, 255]]   # blue intensities
    ]),
    np.array([
        [[0, 0, 255], [0, 0, 255]],
        [[0, 255, 0], [0, 255, 0]],
        [[255, 0, 0], [255, 0, 0]]
    ])
]
write_gif(dataset, 'rgbbgr.gif', fps=5)

# or for just a still GIF
write_gif(dataset[0], 'rgb.gif')

Installation

Either:

pip install array2gif

or:

pip install git+https://github.com/tanyaschlusser/array2gif.git#egg=array2gif

Release History

1.0.4 (2018-06-22)

Bugfixes

  • Fixed issue where error was raised when non-integer dataset is used: instead now it is cast to uint8 and a warning is raised if there’s a difference between the two images.

  • Addressed issue where no error is raised when there are more colors than possible in a GIF (256 max). Although it is possible to have a separate palette for every single frame, this is not implemented right now, and the initial global palette is used for the entire animation.

1.0.3 (2018-06-02)

Bugfixes

  • Did not bump version in documentation last times.

1.0.1 (2018-06-02)

Bugfixes

  • Fixed issue where the width and height of an image are swapped. This is clear in image editors but was not obvious when viewed in Chrome.

1.0.0 (2018-05-23)

Improvements

  • It is now possible to use PIL ordering of data (rows x cols x rgb) in addition to the original ordering (rgb x rows x cols).

Bugfixes

  • Fixed issue where array2gif would raise ValueError when using a 4D NumPy array with perfectly valid data. Now it is possible to use either a list of 3D NumPy arrays, or a 4D NumPy array for animated gifs.

0.1.0 (2016-09-30)

Initial release

  • One single function, write_gif.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

array2gif-1.0.4.tar.gz (8.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

array2gif-1.0.4-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

array2gif-1.0.4-py2-none-any.whl (7.8 kB view details)

Uploaded Python 2

File details

Details for the file array2gif-1.0.4.tar.gz.

File metadata

  • Download URL: array2gif-1.0.4.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for array2gif-1.0.4.tar.gz
Algorithm Hash digest
SHA256 bfb92520109af44f5f066fd8dd5e05eda5918d8c771c03a65dad7a7feb178415
MD5 168a2d5ad8416ab5d0515e08535c80df
BLAKE2b-256 0c68b9100d877ba177e9841e0790480a9620c169166a4676538e553b1206ecf3

See more details on using hashes here.

File details

Details for the file array2gif-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for array2gif-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b34b6fe589a8044c2d35a39f1f04895b57304894cbe67695ea0f068aa6a3c43c
MD5 09127611cd05eb6a19cb03894100e23e
BLAKE2b-256 42f44dd66a8b65738ea8f2739a48d0e1a79e6a77c0cfb4b35a890eb9792dc861

See more details on using hashes here.

File details

Details for the file array2gif-1.0.4-py2-none-any.whl.

File metadata

File hashes

Hashes for array2gif-1.0.4-py2-none-any.whl
Algorithm Hash digest
SHA256 112529fd6103a40c2111202d32c9b8026d2796870e9df70d6b5881e84f6104fa
MD5 f09f8f99f9bb94b0623a41e32ff0bbf4
BLAKE2b-256 46269e21295f863b6706a9e21fd6685cb7e505d3f225bb33650a791a2534e0a4

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.4 This release

3 files

1.0.3

3 files

1.0.2

3 files

1.0.1

3 files

1.0.0

3 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page