Download the PHP package brammo/image without Composer
On this page you can find all versions of the php package brammo/image. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package image
Image helper
A CakePHP plugin for image manipulation
Requirements
- PHP 8.1+
- CakePHP 5.0+
Installation
You can install this plugin using Composer:
Load the Plugin
Add the following to your Application.php:
Or load via command line:
Usage
Load the helpers in your AppView.php:
ImageHelper
Process and cache images with automatic resizing, cropping, and fitting operations. Supports GD, ImageMagick, and libvips image processing libraries via Intervention Image.
Installation
The ImageHelper requires the Intervention Image library (installed automatically):
For libvips support (optional):
Loading the Helper
Configuration Options
| Option | Default | Description |
|---|---|---|
tempFolder |
/thumb |
Directory to store cached images (relative to webroot) |
driver |
auto |
Image processing driver. Auto-detection priority: imagick > vips > gd |
backgroundColor |
#ffffff |
Background fill color for the fit method (hex code) |
Methods
resize()
Scale image to fit within specified dimensions while maintaining aspect ratio.
crop()
Crop image to exact dimensions from center. Image is scaled to cover the target dimensions, then center-cropped.
fit()
Fit image within dimensions and fill remaining space with background color.
getDriverInfo()
Get information about available image processing drivers.
Cache Path Structure
Processed images are cached with the following path structure:
| Method | Suffix | Example |
|---|---|---|
| resize | (none) | /thumb/200x200/images/products/photo.jpg |
| crop | c |
/thumb/200x200c/images/products/photo.jpg |
| fit | f |
/thumb/200x200f/images/products/photo.jpg |
The original directory structure is preserved to avoid filename collisions from different folders.
Supported Formats
| Format | Extension |
|---|---|
| JPEG | jpg, jpeg |
| PNG | png |
| GIF | gif |
| WebP | webp |
| AVIF | avif |
| BMP | bmp |
Error Handling
- If the source image doesn't exist, the original path is returned
- If processing fails, the original path is returned
- If the cache directory is not writable, a
RuntimeExceptionis thrown
Example Usage in Templates
Tests
Run the test suite with PHPUnit:
Code Quality
Run code style checks:
Fix code style issues:
Static Analysis
Run PHPStan and Psalm:
Or run them individually:
License
This plugin is licensed under the MIT License.
Author
Roman Sidorkin - [email protected]
All versions of image with dependencies
cakephp/cakephp Version ^5.0
intervention/image Version ^3.11
intervention/image-driver-vips Version ^1.0