Agent skill
pillow
Python Imaging Library fork for image processing, format conversion, and manipulation.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/skills-skilldoai-skilldo-9
SKILL.md
Imports
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFilter
from PIL import ImageEnhance
from PIL import ImageCms
from PIL import ExifTags
Core Patterns
Opening and Saving Images
from PIL import Image
img = Image.open("input.png")
print(img.size, img.mode, img.format)
img.save("output.jpg", quality=95)
img.save("output.webp", lossless=True)
Resizing and Thumbnails
from PIL import Image
img = Image.open("photo.jpg")
resized = img.resize((800, 600), Image.Resampling.LANCZOS)
thumbnail = img.copy()
thumbnail.thumbnail((200, 200))
thumbnail.save("thumb.jpg")
Color Mode Conversion
from PIL import Image
img = Image.open("photo.jpg")
grayscale = img.convert("L")
rgba = img.convert("RGBA")
Cropping and Rotating
from PIL import Image
img = Image.open("photo.jpg")
cropped = img.crop((left, upper, right, lower))
rotated = img.rotate(45, expand=True, fillcolor=(255, 255, 255))
flipped = img.transpose(Image.Transpose.FLIP_LEFT_RIGHT)
Drawing on Images
from PIL import Image, ImageDraw, ImageFont
img = Image.new("RGB", (400, 300), color="white")
draw = ImageDraw.Draw(img)
draw.rectangle([10, 10, 390, 290], outline="black", width=2)
draw.ellipse([50, 50, 200, 200], fill="blue")
draw.text((210, 100), "Hello", fill="black")
img.save("drawn.png")
Applying Filters
from PIL import Image, ImageFilter
img = Image.open("photo.jpg")
blurred = img.filter(ImageFilter.GaussianBlur(radius=5))
sharpened = img.filter(ImageFilter.SHARPEN)
edges = img.filter(ImageFilter.FIND_EDGES)
ICC Color Management
from PIL import ImageCms
srgb_profile = ImageCms.createProfile("sRGB")
transform = ImageCms.buildTransform(
"input.icc", "output.icc", "RGB", "RGB"
)
corrected = ImageCms.applyTransform(img, transform)
Configuration
from PIL import Image
Image.MAX_IMAGE_PIXELS = 200_000_000
Image.warnings.simplefilter("error", Image.DecompressionBombWarning)
Pitfalls
Wrong: Not closing file handles
img = Image.open("large.tiff")
data = img.load()
Right: Use context manager or explicit close
with Image.open("large.tiff") as img:
data = img.load()
img.save("output.tiff")
Wrong: Using deprecated resampling constants
resized = img.resize((100, 100), Image.ANTIALIAS)
Right: Use Image.Resampling enum
resized = img.resize((100, 100), Image.Resampling.LANCZOS)
Wrong: Saving RGBA as JPEG
rgba_img = Image.open("logo.png")
rgba_img.save("logo.jpg")
Right: Convert to RGB first
rgba_img = Image.open("logo.png")
rgb_img = rgba_img.convert("RGB")
rgb_img.save("logo.jpg")
References
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?