Download the PHP package rafoabbas/laravel-image-proxy without Composer
On this page you can find all versions of the php package rafoabbas/laravel-image-proxy. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-image-proxy
Laravel Image Proxy
On-the-fly image transformation, AVIF/WebP conversion, and caching proxy for Laravel.
Features
- Automatic AVIF/WebP conversion with content negotiation (Accept header)
- Resize, crop, and quality control via query parameters
- Visual effects: blur, sharpen, grayscale, brightness, contrast
- Rotation and flip (horizontal, vertical, both)
- Watermark overlay with configurable position, opacity, and size
- Focal point crop for smart cropping around a point of interest
- Border radius (rounded corners) and padding with background color
- LQIP (Low Quality Image Placeholder) support
- Signed URLs with HMAC-SHA256 for abuse prevention
- GD and Imagick driver support
- Disk-based caching with configurable storage backend
- Cache locking to prevent duplicate processing
- Memory guard to reject oversized images
- External URL proxying with domain allowlist and SSRF protection
- Remote disk (S3, R2, GCS) original caching to reduce repeated downloads
ImageProxyfacade and@imageSrcsetBlade directive- Artisan command for cache management (age-based, size-based cleanup)
- Supports Laravel 10, 11, 12, and 13
Requirements
- PHP 8.2+
- GD extension (
ext-gd) or Imagick extension (ext-imagick) - Laravel 10.x / 11.x / 12.x / 13.x
Installation
The package auto-discovers its service provider. Publish the config file:
Configuration
After publishing, edit config/image-proxy.php:
Usage
Basic
Once installed, images are served through the /img/{path} route:
This reads photos/landscape.jpg from the configured source disk, converts it to the best format supported by the client (AVIF > WebP), caches the result, and returns it with proper Cache-Control, ETag, Vary, and Content-Type headers.
Query Parameters
| Parameter | Type | Description |
|---|---|---|
w |
int | Target width (clamped to max_width) |
h |
int | Target height (clamped to max_height) |
fit |
string | Resize mode: crop for cover-fit |
q |
int | Output quality (clamped between min/max) |
lqip |
bool | Return a 20px low-quality placeholder |
blur |
int | Blur radius, 0–max_blur (default 50) |
sharpen |
int | Sharpen amount, 0–100 |
grayscale |
bool | Convert to grayscale |
brightness |
int | Brightness adjustment, -100 to 100 |
contrast |
int | Contrast adjustment, -100 to 100 |
rotate |
int | Rotation in degrees (mod 360) |
flip |
string | Flip: h (horizontal), v (vertical), both |
watermark |
string | Path to watermark image on watermark disk |
watermark_position |
string | Watermark position (see below) |
watermark_alpha |
int | Watermark opacity, 0–100 (default 50) |
watermark_size |
int | Watermark width as % of image, 1–100 (default 25) |
watermark_padding |
int | Watermark padding from edge, 0–100px (default 10) |
focal_x |
float | Focal point X, 0.0–1.0 (used with w + h) |
focal_y |
float | Focal point Y, 0.0–1.0 (used with w + h) |
border_radius |
int | Rounded corners in pixels (clamped to max_border_radius) |
padding |
int | Padding in pixels (clamped to max_padding) |
bg |
string | Background hex color for padding/rotation (e.g. ff0000 or f00) |
Examples:
Effects
Apply visual effects to any image:
Combine effects with resize:
Rotation & Flip
The bg parameter sets the background color for areas exposed by rotation. Defaults to white.
Watermark
Overlay a watermark image on any processed image:
Watermark positions: top-left, top, top-right, left, center, right, bottom-left, bottom, bottom-right
Watermark images are read from the watermark_disk (falls back to source_disk). Returns 404 if the watermark file doesn't exist.
Focal Point Crop
Crop around a specific point of interest instead of the center:
Both focal_x and focal_y must be provided along with w and h. Values are clamped to 0.0–1.0, where (0,0) is the top-left corner and (1,1) is the bottom-right.
Border Radius & Padding
Add rounded corners and padding:
Generating URLs
Using the Facade
When URL signing is enabled, all URLs generated through the facade are automatically signed.
Using the Blade Directive
This generates a complete <img> tag with srcset, sizes, loading="lazy", and decoding="async" attributes.
Using Route Helper
Note: The route helper does not support signed URLs. Use the
ImageProxyfacade when signing is enabled.
URL Signing
Enable signed URLs to prevent unauthorized transformations:
When enabled, all requests must include a valid s parameter. URLs without a valid signature receive a 403 response.
Content Negotiation (AVIF/WebP)
The proxy automatically selects the best output format based on the client's Accept header:
- If the client supports AVIF and
'avif'is in theformatsconfig → serves AVIF - If the client supports WebP and
'webp'is in theformatsconfig → serves WebP - Falls back to the last format in the list
The response includes a Vary: Accept header for proper CDN caching.
Note: AVIF encoding with the GD driver requires PHP 8.1+ with libavif. The Imagick driver provides more reliable AVIF support.
LQIP (Low Quality Image Placeholder)
Request a tiny placeholder image for lazy loading:
This returns a 20px wide, quality-20 thumbnail (typically under 1KB) that can be used as a blur-up placeholder.
External URL Proxying
Add allowed domains to the config:
Then pass the full URL as the path:
The proxy includes SSRF protection: localhost, private IPs, and reserved ranges are blocked.
Remote Disk Caching
When using remote disks like S3 or R2 as the source, originals are automatically cached to the local cache disk. This avoids re-downloading the same file on subsequent requests with different transformation parameters.
Disable with 'cache_remote_originals' => false in the config.
Rate Limiting
The package does not include built-in rate limiting. Use Laravel's throttle middleware on the image proxy route:
Or apply more granular throttling with a custom rate limiter:
Cache Management
Clear the cache using the Artisan command:
Testing
Code Style
License
MIT
All versions of laravel-image-proxy with dependencies
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
illuminate/console Version ^10.0|^11.0|^12.0|^13.0
illuminate/routing Version ^10.0|^11.0|^12.0|^13.0
intervention/image Version ^3.0