spatie/image
Expressive PHP image manipulation by Spatie. Load an image, chain operations like resize/crop, rotate, greyscale, brightness, sharpen, and quality, then save. Supports common formats and integrates cleanly in Laravel or any PHP app.
Feature Development:
Roadmap Prioritization:
Build vs. Buy:
Use Cases:
Adopt this package if:
Look elsewhere if:
sharp for Node)."This package lets us own our image processing—faster, cheaper, and more reliably than third-party APIs."
Ask: "Should we prioritize reducing our image-processing costs by 70% while improving upload speeds?"
"A battle-tested, Laravel-native library for image manipulation with zero dependencies beyond GD/Imagick."
Why This Over Alternatives:
| Feature | spatie/image |
Intervention Image | Cloudinary API | Custom GD Code |
|---|---|---|---|---|
| Laravel Integration | ✅ Native | ❌ Manual | ❌ API Call | ❌ Manual |
| Expressive API | ✅ Chaining (e.g., ->resize()->watermark()) |
✅ | ❌ Limited | ❌ Verbose |
| Multi-Driver | ✅ GD/Imagick/Vips | ✅ GD/Imagick | ❌ N/A | ❌ Single |
| Performance | ✅ Optimized (~50ms) | ✅ (~60ms) | ⚠️ Latency | ⚠️ Depends |
| Maintenance | ✅ Actively Updated | ⚠️ Stable but Slow | ❌ Vendor | ❌ You |
| Format Support | ✅ WebP/AVIF/HEIC | ❌ Limited | ✅ Broad | ❌ Manual |
Key Advantages:
Developer Experience:
Image::load()->resize()->greyscale()->save()).Performance:
Reliability:
Extensibility:
uploaded → auto-process image).resize:large-thumbnail).Migration Path:
Intervention Image with a drop-in swap (similar API, better performance).Example Workflow (Laravel):
// In a controller or job:
use Spatie\Image\Image;
public function uploadProfilePicture(Request $request) {
$image = Image::load($request->file('avatar'))
->resize(500, 500, fn($constraint) => $constraint->aspectRatio())
->watermark(public_path('logo.png'), 0.2)
->save(public_path("avatars/{$request->user()->id}.webp"));
return redirect()->back()->with('success', 'Profile updated!');
}
Risks/Mitigations:
How can I help you explore Laravel packages today?