Placeholders & Dithering
blurhash(int $width = 32, int $height = 32, int $componentsX = 4, int $componentsY = 3)
Limited availability
Only supported on Imagine and Intervention.
CFCNIMIMIMIXIPIVTHWS
Generate compact placeholder images using DCT encoding. Produces a tiny representation of the image that can be decoded client-side for a blurred preview.
$placeholder = $image->blurHash();
echo $placeholder; // cached blurhash image URL
Parameters
| Parameter | Default | Description |
|---|---|---|
$width |
32 |
Sampling width |
$height |
32 |
Sampling height |
$componentsX |
4 |
Horizontal frequency components |
$componentsY |
3 |
Vertical frequency components |
$image->blurHash(width: 64, height: 64);
$image->blurHash(componentsX: 6, componentsY: 4); // more detail
As data URI
Inline the blurhash directly in HTML without a cache file:
$dataUri = $image->blurHash()->toDataUri();
// → data:image/png;base64,...
BlurHash is only available with the local backends, InterventionProvider and ImagineProvider.
thumbhash(int $width = 32, int $height = 32)
Limited availability
Only supported on Imagine and Intervention.
CFCNIMIMIMIXIPIVTHWS
Generate a compact placeholder image using the ThumbHash algorithm. ThumbHash preserves alpha and generally produces a more faithful preview at the same byte budget as BlurHash, while BlurHash has wider client-library adoption.
$placeholder = $image->thumbHash();
echo $placeholder; // cached thumbhash image URL
Parameters
| Parameter | Default | Description |
|---|---|---|
$width |
32 |
Output preview width in pixels |
$height |
32 |
Output preview height in pixels |
Unlike BlurHash, ThumbHash does not expose basis-function component counts — the algorithm selects them internally from the source aspect ratio.
As data URI
$dataUri = $image->thumbHash()->toDataUri();
// → data:image/png;base64,...
ThumbHash is only available with the local backends, InterventionProvider and ImagineProvider.
dither(DitherAlgorithm $algorithm = DitherAlgorithm::Atkinson)
Limited availability
Only supported on Imagine and Intervention.
CFCNIMIMIMIXIPIVTHWS
Reduce colors using error-diffusion dithering for an artistic or retro effect.
use Timber\Chainsaw\Enum\DitherAlgorithm;
$image->dither(); // Atkinson (default)
$image->dither(DitherAlgorithm::FloydSteinberg);
| Algorithm | Characteristics |
|---|---|
Atkinson |
Sharper, loses 2/8 of error intentionally. Better for text and high-contrast images. |
FloydSteinberg |
Distributes all error. Smoother gradients, more detail in photos. |
Dithering is only available with the local backends, InterventionProvider and ImagineProvider.
dpr(float $ratio)
Limited availability
Only supported on Cloudflare, Cloudinary, Imagekit and Imgix.
CFCNIMIMIMIXIPIVTHWS
- Cloudflare / Imgix
- Native `dpr=` URL parameter.
- Cloudinary
- Native `dpr_` URL parameter.
- Imagekit
- Native `dpr-` URL parameter.
- Imagor / Imgproxy / Intervention / Thumbor / Wserv
- Computed: dimensions multiplied at URL-build time. User-visible bytes are identical, but CDN-cached URLs differ.
DPR multiplies size manipulators only (width, height, cover, pad,
contain, stretch, manualCrop, scale). Combine with a size anchor
to take effect. Aspect-ratio manipulators (padToRatio, cropToRatio)
and effect manipulators (blur, border, sharpen) compose with DPR
but their own parameters are not scaled.
Apply a device-pixel-ratio multiplier to output dimensions. Typically used with responsive srcset at 1x, 2x, 3x.
$image->width(800)->dpr(2); // requests a 1600px-wide variant
The multiplier is honoured by URL providers that expose a native DPR knob (Cloudflare dpr=, Cloudinary dpr_, ImageKit dpr-, Imgix dpr=). On Imgproxy, Imagor, Thumbor, Wserv, and the local providers (Intervention, Imagine), a pre-dispatch DprNormalizer rewrites the size manipulators in the chain — the user-visible output is identical; only the encoded URL differs.