Crop - Intelligent Image Cropping Library
A modern PHP library for intelligent image cropping with multiple algorithms. This is a maintained fork of the original stojg/crop library with modern improvements.
โจ Key Features
- ๐ฏ Three intelligent cropping algorithms: Center, Entropy, and Balanced
- ๐ Modern PHP 8.3+ compatibility with strict typing
- ๐ PHPStan level 8 compliant for maximum type safety
- ๐งช Comprehensive test suite with PHPUnit 11+
- ๐ฆ Simple installation via Composer
- ๐ง Flexible API with method chaining support
๐ Quick Start
Installation
1
composer require drzippie/crop
Basic Usage
1
2
3
4
5
6
use drzippie\crop\CropEntropy;
// Create cropper and process image
$crop = new CropEntropy('path/to/image.jpg');
$result = $crop->resizeAndCrop(300, 200);
$result->writeImage('path/to/output.jpg');
๐ Cropping Strategies
Strategy | Description | Best For |
---|---|---|
CropCenter | Simple center-based cropping | Fast processing, uniform crops |
CropEntropy | Edge-detection based cropping | Preserving important details |
CropBalanced | Weighted center of interest | Balanced composition |
๐ Documentation
- Installation Guide - Setup and requirements
- Usage Guide - Basic and advanced usage
- Cropping Strategies - Detailed algorithm explanations
- Examples - Practical examples with code
- API Reference - Complete API documentation
๐ง Requirements
- PHP 8.3 or higher
- ImageMagick extension with sRGB colorspace (version 6.7.5-5 or higher)
๐ค Contributing
Contributions are welcome! Please feel free to submit issues and enhancement requests.
๐ License
This project is licensed under the BSD-2-Clause License - see the LICENSE file for details.
This library is actively maintained and continues the legacy of the original stojg/crop project.