Skip to main content

A package for creating pixelated GIFs from images

Project description

pixelmagic

pixelmagic is a Python package for creating pixelated GIFs from image files.

Installation

To install the package, run the following command:

pip install pixelmagic

Check if required packages are installed and install them if necessary:

import os
import subprocess


def install(package):
    subprocess.check_call(['pip', 'install', package])


# Check if required packages are installed and install them if necessary
try:
    import imageio
except ImportError:
    install('imageio')
    import imageio

try:
    from PIL import Image
except ImportError:
    install('Pillow')
    from PIL import Image

Usage

Here's an example of how to create a pixelated GIF using pixelmagic:

from pixelmagic.pixelmagic import create_pixelated_gif

image_path = 'path/to/image.jpg'
duration = 0.1
loops = 0
start_pixel_size = 20
output_path = 'path/to/output.gif'
reverse = False  # Optional

create_pixelated_gif(image_path, duration, loops, start_pixel_size, output_path, reverse)

Function Reference

def create_pixelated_gif(image_path: str, duration: float, loops: int, start_pixel_size: int = 20,
                         output_path: str = '', reverse: bool = False) -> str:
    """Create a pixelated GIF from an image file and save it to disk.

    Args:
        image_path (str): The path to the image file.
        duration (float): The duration of each frame in the GIF.
        loops (int): The number of times the GIF should loop. Use 0 for infinite loops.
        start_pixel_size (int): The starting pixel size of the pixelation effect. Default is 20.
        output_path (str): The path to the output file. If not specified, the GIF will be saved to the root directory.
        reverse (bool): If True, the function will create a GIF that transitions from the pixelated image to the
        original image.

    Returns:
        str: The path to the output file. The pixelated GIF is saved to disk.

    Raises:
        FileNotFoundError: If the image file does not exist.
        ZeroDivisionError: If the start_pixel_size is less than or equal to the end_pixel_size.

    """

License

pixelmagic is licensed under the MIT License - see the LICENSE file for details.

Error Handling

create_pixelated_gif raises a FileNotFoundError if the image file does not exist, and a ZeroDivisionError if the start_pixel_size is less than or equal to the end_pixel_size.

Project details


Release history Release notifications | RSS feed

This version

1.0

Download files

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

Source Distribution

pixelmagic-1.0.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

pixelmagic-1.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file pixelmagic-1.0.tar.gz.

File metadata

  • Download URL: pixelmagic-1.0.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for pixelmagic-1.0.tar.gz
Algorithm Hash digest
SHA256 efefcacb60757d1dc3ff8a2239db0e6605f4b03c90d28b3b1f787a32f7e51f7a
MD5 129966ff00562cd66b7818b7f2cd9a00
BLAKE2b-256 16e496e2766a461902a722cd8ba1e94f99e8a4c089c38c7e493c48db94e23213

See more details on using hashes here.

File details

Details for the file pixelmagic-1.0-py3-none-any.whl.

File metadata

  • Download URL: pixelmagic-1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for pixelmagic-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0331942a7799026269429823d71881aa09d114020e17dc63f212652c52c7a534
MD5 0f3c500b7dcf5061653a49063786fb5e
BLAKE2b-256 4394573cbe4bffd82fa443b93910bc7357c6d1a26b4bee80139a1697ce1bea7a

See more details on using hashes here.

Supported by

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