Registry / data / pilkit

pilkit

JSON →
library3.0pypypi✓ verified 84d ago

PILKit is a collection of utilities and processors built on top of the Python Imaging Library (PIL), primarily Pillow. It simplifies common image manipulation tasks by providing an easy-to-use API for operations like resizing, adjusting, and cropping. The current stable version is 3.0, released in September 2023, and the library maintains an active development cadence.

pip install pilkit
INSTALL
IMPORT
SIG · PILKIT
P
pilkit
datapythonv3.0
Install
2.1s avg
Import
88ms
Disk
64MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.940 runs
installs and imports cleanly · install 0.0s · import 0.092s · 92.2MB
glibc
py 3.103.940 runs
installs and imports cleanly · install 2.1s · import 0.083s · 38MB
64MB installed
● package 64MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ResizeToFit
from pilkit.processors import ResizeToFit
ProcessorPipeline
from pilkit.processors import ProcessorPipeline
prepare_image
from pilkit.utils import prepare_image
from pilkit.processors import prepare_image
Image preparation utilities are in `pilkit.utils`, not `pilkit.processors`.
save_image
from pilkit.utils import save_image
from PIL.Image import save
The `pilkit.utils.save_image` utility handles common PIL saving errors, such as 'Suspension not allowed here'.

This quickstart demonstrates how to use a PILKit processor (ResizeToFit) to modify an image. It also shows the recommended way to save the processed image using `pilkit.utils.save_image` to handle potential PIL errors. Ensure Pillow is installed before running.

import os from PIL import Image from pilkit.processors import ResizeToFit from pilkit.utils import save_image # Create a dummy image for demonstration try: img = Image.new('RGB', (200, 150), color = 'red') img.save('original_image.png') except ImportError: print("Pillow not installed. Please install it with 'pip install Pillow'.") exit() # Define a processor processor = ResizeToFit(width=100, height=100, upscale=False) # Process the image original_image = Image.open('original_image.png') processed_image = processor.process(original_image) # Save the processed image using pilkit's utility save_image(processed_image, 'processed_image.png', 'PNG') print("Original image saved as original_image.png") print("Processed image (resized to fit 100x100) saved as processed_image.png") # Clean up (optional) os.remove('original_image.png') os.remove('processed_image.png')
Debug
Known issues
breakingThere is no explicit changelog or migration guide available between major versions, specifically from 2.x to 3.x. Users upgrading major versions may need to inspect the codebase for changes.
fix
Review the GitHub repository's commit history and source code changes when migrating between major versions.
affects: 2.x to 3.x
gotchaPILKit relies on Pillow (or the deprecated PIL) for its core image handling. Pillow is a peer dependency and must be installed separately (e.g., `pip install Pillow`) for PILKit to function correctly.
fix
Always ensure Pillow is installed in your environment alongside PILKit: `pip install Pillow`.
affects: All versions
gotchaWhen saving processed images, direct use of `PIL.Image.save()` can sometimes lead to 'Suspension not allowed here' errors with certain image formats or operations. PILKit provides `pilkit.utils.save_image` to gracefully handle these common issues.
fix
Prefer `from pilkit.utils import save_image` and use it to save your images, instead of `PIL.Image.save()` directly.
affects: All versions
Errors
Common errors & fixes
ImportError: PILKit was unable to import the Python Imaging Library. Please confirm it`s installed and available on your current Python path.
PILKit cannot find the underlying Pillow library, often due to Pillow not being installed in the active Python environment or issues with the Python path.
fix
Ensure Pillow is correctly installed in your current Python environment by running `pip install Pillow`.
ModuleNotFoundError: No module named 'PIL'
The Pillow library, which provides the 'PIL' namespace for image processing, is not installed or is not accessible in the current Python environment.
fix
Install the Pillow library using pip: `pip install Pillow`.
AttributeError: module 'PIL' has no attribute 'Image'
This error typically occurs when a developer tries to access 'Image' directly through the 'PIL' module (e.g., `PIL.Image.open()`) after importing 'PIL' generally, instead of specifically importing 'Image' from 'PIL'.
fix
Import the `Image` module explicitly from `PIL`: `from PIL import Image`, then use `Image.open()`.
Upgrade
Version history
3.0latest on PyPI · released Sep 27, 2023
Audit
Dependencies
PillowrequiredPILKit builds on Pillow (a fork of PIL) for all image processing functionality. Pillow must be installed separately.
Agent activity
2 hits · last 30 days
node
2
Resources
pilkit — pip install pilkit · libregistry