Chainsaw

Fluent image manipulation library for PHP 8.4+ with pluggable backends.

$image = $factory->image('photo.jpg')
    ->crop(800, 600)
    ->format(Format::Webp)
    ->quality(85);

echo $image; // cached URL or CDN transformation URL

Key ideas

  • Immutable fluent API – every method returns a new Image, safe to branch and reuse
  • Pluggable providers – process locally (Intervention, Imagine), or generate transformation URLs for eight CDN services
  • Responsive built-insrcset, <picture>, art direction, format negotiation
  • Twig integration – filters and functions for template-driven image handling
  • Presets – reusable manipulation chains registered on the factory

Providers

Provider Processing Output
InterventionProvider Local (GD / Imagick / libvips) Cached files + URLs
ImagineProvider Local (GD / Imagick / Gmagick) Cached files + URLs
CloudflareProvider Remote CDN Transformation URLs
CloudinaryProvider Remote CDN Transformation URLs
ImagekitProvider Remote CDN Transformation URLs
ImgixProvider Remote CDN Transformation URLs
ImgproxyProvider Remote CDN (self-hosted) Transformation URLs
ThumborProvider Remote CDN (self-hosted) Transformation URLs
ImagorProvider Remote CDN (self-hosted) Transformation URLs
WservProvider Remote CDN (free public) Transformation URLs

Quick example

use Timber\Chainsaw\Enum\Format;
use Timber\Chainsaw\Metadata\ImageMetadata;

$hero = $factory->image('hero.jpg', new ImageMetadata(1920, 1080))
    ->crop(1200, 600)
    ->widths(1200, 800, 400)
    ->formats(Format::Webp);

echo $hero->img(['alt' => 'Hero', 'loading' => 'lazy']);

Outputs a <picture> element with WebP sources and JPEG fallback, each at three widths.