Image Processing

Process images for web development — resize, crop, trim whitespace, convert formats (PNG/WebP/JPG), optimise file size, generate thumbnails, create OG

What Is Image Processing?

Image processing refers to the manipulation and transformation of digital images to achieve specific visual or technical goals. In web development, this often involves resizing, cropping, optimizing, and converting images to ensure they load quickly, display crisply, and meet branding or social sharing requirements. The Claude Code skill "Image Processing" is a developer tool for automating these tasks using Python's Pillow library, without the need for external dependencies like ImageMagick. It streamlines essential image operations for web projects, balancing automation with the flexibility to handle custom workflows.

Why Use Image Processing?

Modern web applications demand high-quality visuals that do not compromise performance. Large, poorly optimized images can lead to slow page loads, negatively affecting SEO and user experience. Additionally, different use cases—thumbnails, Open Graph (OG) cards, or mobile banners—require images in various sizes and formats. Manual processing is time-consuming and error-prone.

The "Image Processing" skill addresses these challenges by:

  • Automating repetitive tasks: Resize, crop, trim, and convert images in bulk or individually with simple commands.
  • Reducing file sizes: Optimize images for faster load times without noticeably degrading quality.
  • Standardizing outputs: Ensure consistent aspect ratios and file formats for assets across a project.
  • Improving workflow efficiency: Eliminate the need for graphical editors or complex command-line tools like ImageMagick.
  • Supporting modern formats: Convert images to WebP for superior compression.

By integrating image processing into your development workflow, you can ensure your web assets are performant, visually consistent, and ready for a wide range of devices and platforms.

How to Get Started

The skill includes a command-line tool, img-process, located in the bin/ directory. Before using it, ensure you have Python installed along with the Pillow library:

pip install Pillow

Once Pillow is available, you'll be able to perform common image tasks via the CLI. Here are a few examples:

  • Resize an image:

    img-process resize hero.png --width 1920
  • Convert a PNG to WebP:

    img-process convert logo.png --format webp
  • Trim whitespace from a logo:

    img-process trim logo-raw.jpg -o logo-clean.png --padding 10
  • Generate a thumbnail:

    img-process thumbnail photo.jpg --size 200
  • Optimize an image for the web:

    img-process optimise hero.jpg --quality 85 --max-width 1920
  • Create an OG card image:

    img-process og-card -o og.png --title "My App" --subtitle "Built for speed"

For batch operations, you can process entire directories:

img-process batch ./images --action convert --format webp -o ./optimised

For advanced or custom requirements, generate a Python script utilizing Pillow based on your needs.

Key Features

The "Image Processing" skill is built for practical web development use cases. Key features include:

  • Resizing: Scale images to any width or height, maintaining aspect ratio as needed.
  • Cropping: Remove unwanted regions from images or trim whitespace automatically.
  • Format Conversion: Convert between PNG, JPG, and WebP with a single command.
  • Optimization: Reduce file size by adjusting quality and dimensions, tailored for web standards.
  • Thumbnails: Generate square or rectangular previews for galleries, blogs, or product lists.
  • OG Card Generation: Quickly create Open Graph images with custom titles and subtitles for social sharing.
  • Batch Processing: Apply actions to entire folders, streamlining asset preparation.
  • No ImageMagick Dependency: All operations use Pillow, simplifying installation and cross-platform compatibility.

Best Practices

To maximize the benefits of this skill in your workflow:

  • Automate asset preparation: Integrate img-process into your build scripts or CI/CD pipelines to ensure all images are optimized before deployment.
  • Choose modern formats: Prefer WebP for most web images, as it provides better compression and quality than older formats.
  • Maintain originals: Always keep a backup of your original images in version control or a separate directory.
  • Use batch processing: For large projects, batch operations save significant time and reduce human error.
  • Adjust quality thoughtfully: When optimizing, test different quality levels to find the best balance between file size and visual fidelity.

Important Notes

  • Pillow is required: The skill depends on the Pillow Python library. Ensure it is installed in your environment.
  • Standard vs. custom workflows: Use img-process for routine operations. For complex tasks (e.g., compositing, conditional edits), generate a custom Pillow script.
  • No ImageMagick needed: All image manipulation occurs via Pillow, avoiding additional dependencies.
  • Input/output formats: While most features support PNG, JPG, and WebP, ensure your source and target formats are compatible with your intended use.
  • Triggering operations: The skill responds to commands like "resize image," "convert to webp," "trim logo," "optimise images," "make thumbnail," "create OG image," "crop whitespace," "process image," or "image too large."
  • Performance considerations: For very large images or intensive batch jobs, monitor memory and CPU usage, especially on shared or limited-resource systems.

By leveraging the "Image Processing" skill, web developers can efficiently produce optimized, visually consistent images tailored to their project's needs, all within a streamlined, Python-based workflow.