Skip to main content

Extensible library for applying animated effects to still images and generating GIFs

Project description

GIF Animator

A Python library for applying animated effects to still images and generating GIFs with alpha transparency.

License: MIT

Features

  • Extensible API: Easily add new animation effects.
  • Preserves Transparency: Ensures smooth rendering with RGBA images.
  • CLI Support: Apply effects from the command line.

Supported Animations

At this time, supported animations are:

  • Jitter: Adds a random shaking effect to images.

Installation

Via PyPi

pip install gifanimator

Via GitHub (developers)

Clone the repository and install dependencies:

git clone https://github.com/DJStompZone/gifanimator.git
cd gifanimator
pip install .

Usage

CLI Usage

Generate a jittery animated GIF:

gifanimator input.png output.gif --params '{"effect": "jitter", "duration": 2, "params": {"frames": 10, "max_shift": 5}}'

Generate a really jittery animated GIF:

gifanimator input.png output.gif --params '{"effect": "jitter", "duration": 2, "params": {"frames": 10, "max_shift": 5}}'  --params '{"effect": "jitter", "duration": 4, "params": {"frames": 30, "max_shift": 15}}'

Note: As seen above, multiple effects can be applied by appending more than one --params argument

Programmatic Usage

from PIL import Image
from gifanimator.jitter_animation import JitterAnimation
from gifanimator.gif_animator import GIFAnimator

img = Image.open("input.png").convert("RGBA")

effect = JitterAnimation(frames=10, max_shift=5)
animator = GIFAnimator(effect)

animator.generate_gif(img, "output.gif")
print("GIF saved as output.gif")

Contributions

Adding New Effects

  1. Create a new animation class by subclassing BaseAnimation.
  2. Implement the apply() method to return a list of frames.
  3. Register the effect in ANIMATION_CLASSES in main.py.

Example:

class MyCustomAnimation(BaseAnimation):
    def apply(self, image):
        # Custom frame processing logic
        return [image]  # Return modified frames

Running Tests

Ensure everything works as expected with:

pytest tests

License

MIT License. See the LICENSE file for details.





Project details


Download files

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

Source Distribution

gifanimator-1.0.8.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

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

gifanimator-1.0.8-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file gifanimator-1.0.8.tar.gz.

File metadata

  • Download URL: gifanimator-1.0.8.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.12.8 Windows/11

File hashes

Hashes for gifanimator-1.0.8.tar.gz
Algorithm Hash digest
SHA256 dbe8dbb64f03ad5b2858531c68191a1b1b68f6f3a85797048f5c36fb7966c060
MD5 0d51ac730397d2ce302a3a1c5e8b74b9
BLAKE2b-256 326a5e2a07bf6209b5605310336f34b8dc048b8f1ab6f69b957952e29aa97cd8

See more details on using hashes here.

File details

Details for the file gifanimator-1.0.8-py3-none-any.whl.

File metadata

  • Download URL: gifanimator-1.0.8-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.12.8 Windows/11

File hashes

Hashes for gifanimator-1.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 bc69558da984640bfb4d09d9b875cb72918162ce8641479c01a8b583e83d2d3d
MD5 d51e463656b62e026f338b107dde369f
BLAKE2b-256 5e69e18665a4116d6883c9e58f7e8f8cf58126c2d696c8f2ad8354b4e137acc8

See more details on using hashes here.

Supported by

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