Skip to content

Commit 66de740

Browse files
committed
making ready for 3.0 release.
1 parent 848d557 commit 66de740

3 files changed

Lines changed: 80 additions & 14 deletions

File tree

CHANGELOG.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Changelog
2+
3+
All notable changes to this project are documented in this file.
4+
5+
## [3.0.0] - 2026-07-22
6+
7+
### Added
8+
9+
- Full **typed public API** (parameters and return types on `ImageResize`).
10+
- **PHPStan** (level 3) and **PSR-12** (PHP-CS-Fixer) in development; CI static-analysis job.
11+
- PHPUnit 10+ configuration migration; tests on PHP 8.2–8.5.
12+
- Additional tests: missing file, `allow_enlarge`, `exact_size` save, WebP/AVIF save, gamma save, stronger filter test.
13+
14+
### Changed
15+
16+
- **Minimum PHP version: 8.1** (`ext-gd`, `ext-fileinfo` required).
17+
- `ImageResize::__construct()` requires `string $filename` (non-empty path, `data:` URL, or valid file).
18+
- `save()` documents `array|false $exact_size` for fixed canvas output.
19+
- `chmod` after save only when saving to a file path string.
20+
- Open `finfo` only when `getimagesize()` fails (faster loads on success path).
21+
22+
### Fixed
23+
24+
- BMP save no longer passes `null` to `imagebmp()` (PHP 8.5 deprecation).
25+
- Removed `finfo_close()` (deprecated in PHP 8.5).
26+
- Constructor no longer uses an invalid `return` statement.
27+
28+
### Removed
29+
30+
- Support for PHP versions below 8.1 (use `2.x` releases).
31+
32+
[3.0.0]: https://github.com/gumlet/php-image-resize/compare/2.1.0...3.0.0

README.md

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,51 @@ If using [Composer](https://getcomposer.org/), in your `composer.json` file add:
2222
```json
2323
{
2424
"require": {
25-
"gumlet/php-image-resize": "2.1.*"
25+
"gumlet/php-image-resize": "^3.0"
2626
}
2727
}
2828
```
2929

30-
For PHP versions >= 7.2 to 8.0, `2.0.x` version of this library should be used.
30+
**PHP 8.1 or newer** is required (with the `gd` and `fileinfo` extensions). For older PHP versions, stay on the 2.x line:
31+
32+
| PHP version | Library version |
33+
|-------------|-----------------|
34+
| 8.1 – 8.5+ | **3.x** (`^3.0`) |
35+
| 7.2 – 8.0 | `2.0.x` |
36+
| 8.0 (legacy)| `2.1.x` (if you were already on it) |
37+
38+
### Upgrading from 2.x to 3.0
39+
40+
3.0 is a **major** release focused on modern PHP, static analysis, and PHP 8.5 compatibility. Behavior is largely the same; most upgrades are about types and environment.
41+
42+
**Requirements**
43+
44+
- PHP **>= 8.1** (2.x supported older PHP).
45+
- `ext-gd` and `ext-fileinfo` (unchanged).
46+
47+
**Breaking / API changes**
48+
49+
- **Typed public API** — Methods and public properties use scalar types and `static` return types (e.g. `resize(int $width, int $height, bool $allow_enlarge = false): static`). Custom subclasses that override methods must match these signatures.
50+
- **`ImageResize::__construct(string $filename)`** — The path must be a non-empty string. Passing `null` is a `TypeError` in PHP 8+ (previously you could pass `null` and get `ImageResizeException`). Use a real path, a `data:` URL, or `ImageResize::createFromString()` for binary data.
51+
- **`ImageResize::createFromString(string $image_data)`** — Only accepts `string`; empty string still throws `ImageResizeException` with message `image_data must not be empty`.
52+
- **`save()` signature** — Documented types: `string|resource|null $filename`, optional `?int $image_type`, `int|string|null $quality`, `?int $permissions`, and `array|false $exact_size` (canvas size `[width, height]`, not a boolean).
53+
- **Class constants** — Crop/flip constants are `public const` on `ImageResize` (same names and values as before).
54+
- **BMP output**`imagebmp()` is called without a invalid third argument (fixes deprecation when quality was `null`).
55+
56+
**Fixes (compatible behavior)**
57+
58+
- MIME detection via `finfo` runs only when `getimagesize()` fails (no `finfo_open` on every load).
59+
- **`chmod`** after save only runs when the destination is a **file path** string (not streams or `null` used by `output()`).
60+
- PHP **8.5**: removed deprecated `finfo_close()` usage.
61+
62+
**Development / quality (library consumers unaffected unless you contribute)**
63+
64+
- PSR-12 via PHP-CS-Fixer (`composer cs-fix` / `cs-check`).
65+
- PHPStan level 3 on `lib/` (`composer phpstan`).
66+
- PHPUnit 10+ config migrated; CI runs tests on PHP 8.2–8.5 and a separate static-analysis job.
67+
- Expanded test suite (missing file, `exact_size`, enlarge, WebP/AVIF save, gamma, filters).
68+
69+
See [CHANGELOG.md](CHANGELOG.md) for the full 3.0.0 release notes.
3170

3271
Otherwise:
3372

@@ -221,6 +260,9 @@ If you would like to save/output in a different image type, you need to pass a (
221260
- `IMAGETYPE_GIF`
222261
- `IMAGETYPE_JPEG`
223262
- `IMAGETYPE_PNG`
263+
- `IMAGETYPE_WEBP` (when GD is built with WebP support)
264+
- `IMAGETYPE_AVIF` (when GD is built with AVIF support)
265+
- `IMAGETYPE_BMP`
224266

225267
This allows you to save in a different type to the source:
226268

@@ -242,7 +284,7 @@ $image->resize(800, 600);
242284
$image->save('image2.jpg');
243285
```
244286

245-
By default they are set to 85 and 6 respectively. See the manual entries for [`imagejpeg()`](http://www.php.net/manual/en/function.imagejpeg.php) and [`imagepng()`](http://www.php.net/manual/en/function.imagepng.php) for more info.
287+
By default they are set to 85, 85 (WebP), 60 (AVIF), and 6 (PNG) respectively. See the manual entries for [`imagejpeg()`](http://www.php.net/manual/en/function.imagejpeg.php) and [`imagepng()`](http://www.php.net/manual/en/function.imagepng.php) for more info.
246288

247289
You can also pass the quality directly to the `save()`, `output()` and `getImageAsString()` methods:
248290

@@ -303,11 +345,10 @@ ImageResize throws ImageResizeException for it's own for errors. You can catch t
303345
It is not to be expected, but should anything go horribly wrong mid way then notice or warning Errors could be shown from the PHP GD and Image Functions (http://php.net/manual/en/ref.image.php)
304346

305347
```php
306-
try{
307-
$image = new ImageResize(null);
308-
echo "This line will not be printed";
348+
try {
349+
new ImageResize('/path/that/does/not/exist.jpg');
309350
} catch (ImageResizeException $e) {
310-
echo "Something went wrong" . $e->getMessage();
351+
echo 'Something went wrong: ' . $e->getMessage();
311352
}
312353
```
313354

composer.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,6 @@
2727
"Gumlet\\": "lib/"
2828
}
2929
},
30-
"autoload-dev":
31-
{
32-
"psr-4":
33-
{
34-
"Gumlet\\": "test/"
35-
}
36-
},
3730
"require-dev":
3831
{
3932
"phpunit/phpunit": "^10.0",

0 commit comments

Comments
 (0)