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
muslpy 3.10–3.940 runs
installs and imports cleanly · install 0.0s · import 0.092s · 92.2MB
glibcpy 3.10–3.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')
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.
fixEnsure 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.
fixInstall 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'.
fixImport 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.