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.6.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.6-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gifanimator-1.0.6.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.6.tar.gz
Algorithm Hash digest
SHA256 f9073a3679ce823a399a46d09d210079a1477bad6b480ce238fd8bf20cf50534
MD5 03d84722442bf221692e829e0a789de3
BLAKE2b-256 8ea2508cc96605b42150cbdb16a3f7b80130e18207fcbf25f7d14c24f388ab60

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gifanimator-1.0.6-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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 38e922c229c619e8d14d3c3801a215443fbf0de6105aa68364050c758dca6caa
MD5 c80cf76c2e95e7be7768f757bdecb867
BLAKE2b-256 5c123e870abd84243d9e169cd79d83b15f389cbb205de172fadb96a8d411a234

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