rokka/imagine-vips
Libvips adapter for Imagine, offering fast, multi-threaded image processing with low memory use. Works via PHP FFI (recommended) or php-vips-ext, plus php-vips classes. Supports common Imagine operations like open, thumbnail, and save; vips 8.7+ recommended.
new \Imagine\Gd\Imagine() or new \Imagine\Imagick\Imagine() with new \Imagine\Vips\Imagine().thumbnail(), resize(), paste()), but some edge cases (e.g., fill(), histogram) are missing (see "Missing stuff" in README).php-vips-ext ≥1.0.8.php-vips (auto-installed via Composer).| Risk Area | Severity | Mitigation |
|---|---|---|
| libvips Version Mismatch | High | Enforce vips ≥8.7 in CI/CD; document min requirements in composer.json. |
| FFI/Extension Dependencies | Medium | Provide clear installation docs for FFI (pecl install ffi) or php-vips-ext. |
| Missing Features | Low | Track unsupported methods (e.g., fill()) in a deprecation/roadmap issue. |
| BC Breaks | Medium | Test against Imagine 1.1.0+ (this package’s baseline). |
| Animated GIF/WebP Quirks | Low | Validate with vips ≥8.9 for delay/frame support. |
roave/security-advisories or custom scripts).Imagine\Image\ImageInterface usage in codebase.README.vips_cache_set_max_mem usage (configurable via constructor).Drawer support).| Component | Compatibility | Notes |
|---|---|---|
| PHP Version | ≥7.1 (PHP 8.0+ recommended) | Test with PHP 8.2+ for FFI stability. |
| Laravel | ✅ Full (Imagine is framework-agnostic) | Use Imagine\Vips\Imagine in Service Providers or Jobs. |
| Existing Imagine | ✅ Drop-in replacement for \Imagine\Gd\Imagine or \Imagine\Imagick\Imagine |
Update config files (e.g., config/filesystems.php). |
| Storage Drivers | ✅ Works with Flysystem, Laravel Filesystem, or direct paths. | No changes needed. |
| Queue Workers | ✅ Ideal for batch processing (low memory, high speed). | Pair with Laravel Queues for async tasks. |
| APIs | ✅ Replace imagick in API responses (e.g., image URLs, transformations). |
Update OpenAPI/Swagger docs if exposing image endpoints. |
Phase 1: Testing (Low Risk)
Imagine\Vips\Imagine.md5_file() to compare hashes).memory_get_usage()).Phase 2: Full Rollout (Medium Risk)
"require": {
"rokka/imagine-vips": "^0.41",
"jcupitt/php-vips": "^2.1",
"ext-ffi": "*" // or php-vips-ext
}
$imagine = new \Imagine\Vips\Imagine([
'vips_cache_set_max_mem' => 100 * 1024 * 1024, // 100MB
]);
libvips installation to pipelines (e.g., apt-get install libvips-dev).Phase 3: Optimization (High Impact)
magicksave (if vips ≥8.7 + ImageMagick):
$imagine->save($path, ['force_magick' => true]);
$imagine->save($path, ['webp_reduction_effort' => 6]); // Max compression
| Feature | Status | Workaround |
|---|---|---|
| Animated GIFs/WebP | ✅ (vips ≥8.7) | Fallback to Imagick if unsupported. |
| SVG/PSD | ❌ (No native support) | Use convertToAlternative() to Imagick. |
fill() method |
❌ (Not implemented) | Implement custom logic or contribute. |
BC Breaks (e.g., Drawer::text()) |
✅ (Handled) | Update calls to use new signatures. |
magicksave after validating stability.libvips must be installed on all servers.libvips version and operations for debugging:
How can I help you explore Laravel packages today?