Download the PHP package guillaumetissier/image-resizer without Composer
On this page you can find all versions of the php package guillaumetissier/image-resizer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download guillaumetissier/image-resizer
More information about guillaumetissier/image-resizer
Files in guillaumetissier/image-resizer
Package image-resizer
Short Description PHP implementation of an image resizer.
License MIT
Homepage https://github.com/guillaumetissier/image-resizer
Informations about the package image-resizer
ImageResizer
A powerful and flexible PHP library for resizing images with configurable validation constraints.
Features
- ๐ฏ Simple API - Intuitive fluent interface for easy image manipulation
- โ๏ธ Configurable - Customizable validation constraints for width, height, ratio, and quality
- ๐ก๏ธ Secure - Pre-configured profiles for different security requirements
- ๐งช Well-tested - Comprehensive test coverage
- ๐ง Extensible - Clean architecture with dependency injection
- ๐ฆ Multiple formats - Support for JPEG, PNG, and GIF
Requirements
- PHP 8.1 or higher
- GD extension or Imagick extension
Installation
Install via Composer:
Quick Start
Usage
Basic Resizing
Multiple Transformations
Quality and Options
Method Chaining
All setter methods return $this for fluent interface:
Configuration Profiles
ImageResizer comes with pre-configured validation profiles for different use cases.
Available Profiles
Profile Specifications
| Profile | Max Width | Max Height | Quality Range | Ratio Range | Use Case |
|---|---|---|---|---|---|
default() |
2000px | 2000px | 0-100 | 0.01-10.0 | Standard usage |
safe() |
8000px | 8000px | 50-95 | 0.1-2.0 | Public websites |
strict() |
4000px | 4000px | 60-90 | 0.5-1.0 | Secure environments |
thumbnail() |
500px | 500px | 70-85 | - | Thumbnails |
web() |
2000px | 2000px | 70-90 | - | Web images |
print() |
10000px | 10000px | 85-100 | - | Print quality |
Custom Configuration
Create your own configuration with specific constraints:
Validation
ImageResizer validates all inputs to ensure safe and consistent image processing.
Automatic Validation
All transformations and options are automatically validated:
Common Exceptions
InvalidRangeException- Value is out of allowed rangeInvalidTypeException- Value has wrong typeInvalidPathException- File path is invalid or file doesn't exist
Validation Examples
Examples
Example 1: User Avatar Processing
Example 2: Batch Processing
Example 3: Creating Thumbnails
Architecture
ImageResizer follows SOLID principles and uses dependency injection for flexibility:
API Reference
ImageResizer
Factory Method
Creates a new ImageResizer instance with optional configuration.
Methods
ImageResizerConfig
Factory Methods
Constructor
Available parameters:
minWidth(int|null) - Minimum width in pixelsmaxWidth(int|null) - Maximum width in pixelsminHeight(int|null) - Minimum height in pixelsmaxHeight(int|null) - Maximum height in pixelsminRatio(float|null) - Minimum aspect ratiomaxRatio(float|null) - Maximum aspect ratiominQuality(int|null) - Minimum quality (0-100)maxQuality(int|null) - Maximum quality (0-100)defaultQuality(int) - Default quality valuedefaultInterlace(bool) - Default interlace setting
Constants
Transformations
Options
Migration from v1.x
Breaking Changes
The constructor is now private. Use the factory method instead:
No Changes Needed
If you were already using ImageResizer::create(), no changes are required:
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
- ๐ง Email: [[email protected]]
- ๐ Issues: GitHub Issues
- ๐ Documentation: Full Documentation
Changelog
See CHANGELOG.md for a detailed list of changes.
Credits
Created and maintained by Guillaume Tissier