crewAIInc/crewAI · error · ProcessingDependencyError
Pillow is required for image resizing
Error message
Pillow is required for image resizing
What it means
resize_image() in crewai_files.processing.transformers lazily imports PIL; if Pillow is not installed it raises ProcessingDependencyError('Pillow is required for image resizing') with dependency='Pillow' and install_command='pip install Pillow'. The library keeps Pillow optional, so the error appears only when an image actually needs resizing (e.g. AUTO mode downsizing an oversized image).
Source
Thrown at lib/crewai-files/src/crewai_files/processing/transformers.py:39
) -> ImageFile:
"""Resize an image to fit within the specified dimensions.
Args:
file: The image file to resize.
max_width: Maximum width in pixels.
max_height: Maximum height in pixels.
preserve_aspect_ratio: If True, maintain aspect ratio while fitting within bounds.
Returns:
A new ImageFile with the resized image data.
Raises:
ProcessingDependencyError: If Pillow is not installed.
"""
try:
from PIL import Image
except ImportError as e:
raise ProcessingDependencyError(
"Pillow is required for image resizing",
dependency="Pillow",
install_command="pip install Pillow",
) from e
content = file.read()
with Image.open(io.BytesIO(content)) as img:
original_width, original_height = img.size
if original_width <= max_width and original_height <= max_height:
return file
if preserve_aspect_ratio:
width_ratio = max_width / original_width
height_ratio = max_height / original_height
scale_factor = min(width_ratio, height_ratio)
View on GitHub (pinned to 754d7323be)
Solutions
- Install Pillow: pip install Pillow (or add it to your project's dependencies / install the image extras of crewai-files if provided).
- Pin it in pyproject/requirements so environments are reproducible.
- Catch ProcessingDependencyError and check .install_command / .dependency for a self-healing message to the operator.
- Pre-resize images upstream (client-side) so AUTO never needs to resize in an environment without Pillow.
Example fix
# before # environment without Pillow new_img = resize_image(file, max_width=1024, max_height=1024) # ProcessingDependencyError # after # shell: pip install Pillow new_img = resize_image(file, max_width=1024, max_height=1024)
Defensive patterns
Strategy: validation
Validate before calling
import importlib.util
if importlib.util.find_spec("PIL") is None and handling == FileHandling.AUTO:
raise RuntimeError("FileHandling.AUTO with images requires Pillow: pip install Pillow") Try / catch
from crewai_files.processing.exceptions import ProcessingDependencyError
try:
out = resize_image(file, max_width, max_height)
except ProcessingDependencyError as e:
if e.dependency == "Pillow":
raise RuntimeError(f"missing optional dependency; run: {e.install_command}") from e
raise Prevention
- Add Pillow to the deployment dependency set whenever images are processed.
- Check importlib.util.find_spec('PIL') at startup and fail fast with a clear message.
- Use the exception's .dependency and .install_command fields for actionable operator messages.
When it happens
Trigger: Running with FileHandling.AUTO (or calling resize_image directly) on an image that exceeds max_width/max_height while Pillow is absent from the environment. Also triggered in slim Docker images or production installs where crewai-files was installed without the image extras.
Common situations: pip install crewai-files without extras in CI/CD; alpine/slim Docker base images; dev machine had Pillow transitively (via another package) but the deploy env does not; venv recreated without Pillow.
Related errors
- Pillow is required for image optimization
- pypdf is required for PDF chunking
- Image '{filename}' width ({width}px) exceeds maximum ({const
- Image '{filename}' height ({height}px) exceeds maximum ({con
- The 'couchbase' package is required to use the CouchbaseFTSV
AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15).
Data as JSON: /api/errors/ec1c5074b7f7ab92.
Report an issue: GitHub.