Placeholders & Dithering
blurhash(int $width = 32, int $height = 32, int $componentsX = 4, int $componentsY = 3)
Limited availability
Only supported on Imagine and Intervention.
BUCFCNGUIMIMIMIXIPIVTHWS
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.
BUCFCNGUIMIMIMIXIPIVTHWS
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.
BUCFCNGUIMIMIMIXIPIVTHWS
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.