Skip to content

Commit 4072776

Browse files
committed
Cleanup.
1 parent ac0b163 commit 4072776

File tree

13 files changed

+918
-53
lines changed

13 files changed

+918
-53
lines changed

CHANGELOG.md

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [1.0.0] - TBD
9+
10+
### Added
11+
- Added `scale()` method to `ImageVariant` for resizing while preserving aspect ratio
12+
- Comprehensive documentation for all available image operations in [docs/Available-Operations.md](/docs/Available-Operations.md)
13+
- Enhanced README with quick examples and upgrade guide
14+
- Support for Intervention Image v3
15+
16+
### Changed
17+
- **BREAKING**: Upgraded to Intervention Image v3 (from v2)
18+
- **BREAKING**: `ImageManager` constructor now requires a `DriverInterface` instance instead of array configuration
19+
```php
20+
// Before (v2):
21+
new ImageManager(['driver' => 'gd'])
22+
23+
// After (v3):
24+
new ImageManager(new \Intervention\Image\Drivers\Gd\Driver())
25+
```
26+
- **BREAKING**: Removed `aspectRatio` parameter from `resize()` method in `ImageVariant`
27+
- `resize()` now always stretches to exact dimensions (does not preserve aspect ratio)
28+
- Use `scale()` instead for aspect ratio preservation (recommended for most cases)
29+
```php
30+
// Before:
31+
->resize(300, 300, true, false) // aspectRatio = true
32+
33+
// After:
34+
->scale(300, 300) // Maintains aspect ratio
35+
// OR
36+
->resize(300, 300) // Stretches to exact 300x300
37+
```
38+
- **BREAKING**: Fixed `crop()` method signature in `ImageVariant` - parameters now in order: width, height, x, y
39+
```php
40+
// Before:
41+
->crop($height, $width, $x, $y)
42+
43+
// After:
44+
->crop($width, $height, $x, $y)
45+
```
46+
- **BREAKING**: `crop()` position parameter now uses named parameter syntax for Intervention Image v3 compatibility
47+
- Updated image encoding from v2's `stream()` to v3's `encodeByExtension()->toFilePointer()`
48+
49+
### Removed
50+
- **BREAKING**: Removed dependency on `guzzlehttp/psr7` (no longer needed with Intervention Image v3)
51+
- **BREAKING**: Removed backward compatibility code for deprecated `aspectRatio` parameter in `resize()` operation
52+
53+
### Fixed
54+
- Fixed compatibility with Intervention Image v3 crop operation using named parameters
55+
- Fixed `OperationsTest` to use proper mocking of `ImageInterface` instead of concrete class
56+
- Updated all documentation examples to use correct Intervention Image v3 API
57+
58+
### Documentation
59+
- Added comprehensive [Available Operations](/docs/Available-Operations.md) guide covering all image manipulation methods
60+
- Updated [Processing Images](/docs/Processing-Images.md) with v3 examples
61+
- Added upgrade notes in README for migrating from v2
62+
- Added clear distinction between `resize()` (exact dimensions) and `scale()` (aspect ratio preserved)
63+
64+
## [0.1.0] - Previous Release
65+
66+
Initial release with Intervention Image v2 support.
67+
68+
---
69+
70+
## Upgrade Guide from 0.x to 1.0
71+
72+
### Step 1: Update ImageManager Instantiation
73+
74+
```php
75+
// Old (v0.x with Intervention Image v2):
76+
use Intervention\Image\ImageManager;
77+
$imageManager = new ImageManager(['driver' => 'gd']);
78+
79+
// New (v1.0 with Intervention Image v3):
80+
use Intervention\Image\ImageManager;
81+
use Intervention\Image\Drivers\Gd\Driver;
82+
$imageManager = new ImageManager(new Driver());
83+
```
84+
85+
### Step 2: Replace aspectRatio Parameter
86+
87+
If you were using `resize()` with `aspectRatio` parameter:
88+
89+
```php
90+
// Old:
91+
$collection->addNew('thumbnail')
92+
->resize(300, 300, true); // aspectRatio = true
93+
94+
// New:
95+
$collection->addNew('thumbnail')
96+
->scale(300, 300); // Use scale() to preserve aspect ratio
97+
```
98+
99+
If you need exact dimensions without aspect ratio:
100+
101+
```php
102+
// Old:
103+
$collection->addNew('exact')
104+
->resize(300, 300, false); // aspectRatio = false
105+
106+
// New:
107+
$collection->addNew('exact')
108+
->resize(300, 300); // resize() now always uses exact dimensions
109+
```
110+
111+
### Step 3: Update Crop Calls (if using coordinate-based cropping)
112+
113+
```php
114+
// Old (wrong parameter order):
115+
->crop($height, $width, $x, $y)
116+
117+
// New (correct parameter order):
118+
->crop($width, $height, $x, $y)
119+
```
120+
121+
### Step 4: Update Test Mocks
122+
123+
If you have custom tests mocking the Image class, update to mock `ImageInterface` instead:
124+
125+
```php
126+
// Old:
127+
use TestApp\Image;
128+
$mock = $this->getMockBuilder(Image::class)...
129+
130+
// New:
131+
use Intervention\Image\Interfaces\ImageInterface;
132+
$mock = $this->createMock(ImageInterface::class);
133+
```
134+
135+
### What Stays the Same
136+
137+
- All other image operations (flip, rotate, sharpen, etc.) work the same way
138+
- Chaining operations works the same way
139+
- The `optimize()` method works the same way
140+
- File storage integration works the same way
141+
142+
### Recommended Changes
143+
144+
While not required, we recommend reviewing your image variants and ensuring you're using the most appropriate method:
145+
146+
- **For thumbnails**: Use `scale()` to maintain aspect ratio
147+
- **For avatars/profile pics**: Use `cover()` to fill exact dimensions
148+
- **For exact sizes (cards/banners)**: Use `resize()` or `cover()` depending on whether you want stretching or cropping
149+
- **For responsive images**: Use `scale()` with different dimensions
150+
151+
See the [Available Operations](/docs/Available-Operations.md) documentation for detailed examples and use cases.

0 commit comments

Comments
 (0)