FaB Boost for Images
A lightweight, open-source image processing microservice that gives any website on-demand resizing, format conversion, and optimisation, without the complexity of a full CDN. Point it at any image URL, add query parameters, and get back a perfectly sized, cached, and optimised result.
Simple URL-Based API
No SDKs, no build steps, no configuration files. Just append parameters to an image URL and get back exactly what you need. Generate responsive <img> tags with full srcset support in seconds.
14 Parameters
Resize, crop, convert formats, adjust brightness and contrast, flip, rotate, blur, sharpen, and set background colours - all through simple query parameters like ?w=800&fm=webp&q=80. Add ?purge=1 to any image URL to clear its cache and force a fresh download.
Two-Layer Caching
Original images are downloaded and cached locally. Every processed variation is cached separately, so subsequent requests are served instantly. Pair with Cloudflare (even the free plan) for a full CDN experience.
Centralised Image Processing
Host one instance and serve optimised images for all your client sites. Domain whitelisting keeps things secure, while each site gets responsive images without needing its own processing pipeline.
How It Works
-
Request any remote image via URL:
img.your-domain.com/client-domain.com/photos/cat.jpg?w=400&fm=webp - On-the-fly transformations: The image is downloaded, processed with your parameters, and cached, all in a single request. Subsequent requests for the same variation are served from cache.
- Supports JPG, PNG, GIF, BMP, WebP, and AVIF for both input and output formats, with automatic quality optimisation.
Ideal For
- Static sites, flat-file CMS platforms, or custom backends that lack built-in image processing
- Agencies managing responsive images across multiple client projects from a single service
- Rapid prototyping where you need optimised images without infrastructure overhead
- Any project where a full image CDN is overkill but raw unoptimised images aren't good enough
PHP Integration Example
A helper function that generates a responsive <img> tag with srcset. Reads the original dimensions, builds breakpoints with wider gaps at larger sizes, and converts to WebP (preserving GIF for animations).
define('FABBOOST_URL', 'https://img.your-domain.com/image/your-site.com');
function fabboost($url, $alt = '', $class = '', $params = '')
{
[$width, $height] = getimagesize('.' . $url) ?: [0, 0];
$fm = pathinfo($url, PATHINFO_EXTENSION) === 'gif' ? 'gif' : 'webp';
$base = FABBOOST_URL . $url . '?v=' . filemtime('.' . $url);
if ($params) $base .= '&' . $params;
$widths = array_filter([300, 550, 950, 1500, 2200, 3050], fn($w) => $w < $width);
$widths[] = $width; // always include original as final breakpoint
$srcset = implode(', ', array_map(
fn($w) => "{$base}&fm={$fm}&w={$w} {$w}w", $widths
));
$cls = $class ? " class=\"{$class}\"" : '';
return "<img{$cls} alt=\"{$alt}\" width=\"{$width}\" height=\"{$height}\""
. " srcset=\"{$srcset}\" src=\"{$base}&fm={$fm}&w=500\">";
}
Usage:
<?= fabboost('/assets/images/photo.jpg', 'A description', 'lazy') ?>
Breakpoints at 300, 550, 950, 1500, 2200, and 3050px, with wider gaps at larger sizes where the visual difference is less noticeable, capped at the original width to avoid upscaling.
Open Source License
This project is open-source and available under the MIT License. Please note it's provided "as-is," without any warranty or liability.
View on GitHub