pixelmagic


Namepixelmagic JSON
Version 1.0 PyPI version JSON
download
home_pagehttps://github.com/madhawap/pixelmagic
SummaryA package for creating pixelated GIFs from images
upload_time2023-05-10 07:12:51
maintainer
docs_urlNone
authormadhawap
requires_python
license
keywords pixelated gif imageio pillow
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pixelmagic

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

## Installation

To install the package, run the following command:

```markdown
pip install pixelmagic
```
Check if required packages are installed and install them if necessary:

```python
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`:

```python
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
```python
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](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`.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/madhawap/pixelmagic",
    "name": "pixelmagic",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "pixelated gif imageio pillow",
    "author": "madhawap",
    "author_email": "madhawa.perera@anu.edu.au",
    "download_url": "https://files.pythonhosted.org/packages/16/e4/96e2766a461902a722cd8ba1e94f99e8a4c089c38c7e493c48db94e23213/pixelmagic-1.0.tar.gz",
    "platform": null,
    "description": "# pixelmagic\n\n`pixelmagic` is a Python package for creating pixelated GIFs from image files.\n\n## Installation\n\nTo install the package, run the following command:\n\n```markdown\npip install pixelmagic\n```\nCheck if required packages are installed and install them if necessary:\n\n```python\nimport os\nimport subprocess\n\n\ndef install(package):\n    subprocess.check_call(['pip', 'install', package])\n\n\n# Check if required packages are installed and install them if necessary\ntry:\n    import imageio\nexcept ImportError:\n    install('imageio')\n    import imageio\n\ntry:\n    from PIL import Image\nexcept ImportError:\n    install('Pillow')\n    from PIL import Image\n```\n\n## Usage\nHere's an example of how to create a pixelated GIF using `pixelmagic`:\n\n```python\nfrom pixelmagic.pixelmagic import create_pixelated_gif\n\nimage_path = 'path/to/image.jpg'\nduration = 0.1\nloops = 0\nstart_pixel_size = 20\noutput_path = 'path/to/output.gif'\nreverse = False  # Optional\n\ncreate_pixelated_gif(image_path, duration, loops, start_pixel_size, output_path, reverse)\n```\n\n## Function Reference\n```python\ndef create_pixelated_gif(image_path: str, duration: float, loops: int, start_pixel_size: int = 20,\n                         output_path: str = '', reverse: bool = False) -> str:\n    \"\"\"Create a pixelated GIF from an image file and save it to disk.\n\n    Args:\n        image_path (str): The path to the image file.\n        duration (float): The duration of each frame in the GIF.\n        loops (int): The number of times the GIF should loop. Use 0 for infinite loops.\n        start_pixel_size (int): The starting pixel size of the pixelation effect. Default is 20.\n        output_path (str): The path to the output file. If not specified, the GIF will be saved to the root directory.\n        reverse (bool): If True, the function will create a GIF that transitions from the pixelated image to the\n        original image.\n\n    Returns:\n        str: The path to the output file. The pixelated GIF is saved to disk.\n\n    Raises:\n        FileNotFoundError: If the image file does not exist.\n        ZeroDivisionError: If the start_pixel_size is less than or equal to the end_pixel_size.\n\n    \"\"\"\n```\n\n## License\n\n`pixelmagic` is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Error Handling\n\n`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`.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A package for creating pixelated GIFs from images",
    "version": "1.0",
    "project_urls": {
        "Homepage": "https://github.com/madhawap/pixelmagic"
    },
    "split_keywords": [
        "pixelated",
        "gif",
        "imageio",
        "pillow"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4394573cbe4bffd82fa443b93910bc7357c6d1a26b4bee80139a1697ce1bea7a",
                "md5": "0f3c500b7dcf5061653a49063786fb5e",
                "sha256": "0331942a7799026269429823d71881aa09d114020e17dc63f212652c52c7a534"
            },
            "downloads": -1,
            "filename": "pixelmagic-1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0f3c500b7dcf5061653a49063786fb5e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 4492,
            "upload_time": "2023-05-10T07:12:48",
            "upload_time_iso_8601": "2023-05-10T07:12:48.291462Z",
            "url": "https://files.pythonhosted.org/packages/43/94/573cbe4bffd82fa443b93910bc7357c6d1a26b4bee80139a1697ce1bea7a/pixelmagic-1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "16e496e2766a461902a722cd8ba1e94f99e8a4c089c38c7e493c48db94e23213",
                "md5": "129966ff00562cd66b7818b7f2cd9a00",
                "sha256": "efefcacb60757d1dc3ff8a2239db0e6605f4b03c90d28b3b1f787a32f7e51f7a"
            },
            "downloads": -1,
            "filename": "pixelmagic-1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "129966ff00562cd66b7818b7f2cd9a00",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3619,
            "upload_time": "2023-05-10T07:12:51",
            "upload_time_iso_8601": "2023-05-10T07:12:51.042243Z",
            "url": "https://files.pythonhosted.org/packages/16/e4/96e2766a461902a722cd8ba1e94f99e8a4c089c38c7e493c48db94e23213/pixelmagic-1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-10 07:12:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "madhawap",
    "github_project": "pixelmagic",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pixelmagic"
}
        
Elapsed time: 0.06690s