Skip to content

Commit 66865f1

Browse files
committed
Merge branch 'next' into develop
2 parents c073d1c + 518b529 commit 66865f1

605 files changed

Lines changed: 25133 additions & 7969 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@
1212
/phpstan.dist.neon export-ignore
1313
/docker-compose.yml export-ignore
1414
/Dockerfile export-ignore
15+
/entrypoint.sh export-ignore
16+
/AGENTS.md export-ignore

.github/workflows/run-tests.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ jobs:
88
strategy:
99
fail-fast: false
1010
matrix:
11-
php: [ '8.1', '8.2', '8.3', '8.4', '8.5' ]
12-
imagemagick: [ '6.9.13-25', '7.1.1-47' ]
11+
php: [ '8.3', '8.4', '8.5' ]
12+
imagemagick: [ '6.9.13-40', '7.1.2-15' ]
13+
imagick: [ '3.8.1' ]
1314

1415
name: PHP ${{ matrix.php }} - ImageMagick ${{ matrix.imagemagick }}
1516

AGENTS.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Intervention Image Agent Guide
2+
3+
This document provides a guide for software engineering agents working on the Intervention Image codebase.
4+
5+
## 1. Project Overview
6+
7+
Intervention Image is a PHP image manipulation library. It provides an expressive, fluent interface to create, edit, and compose images. The library supports both the GD library and Imagick as underlying drivers.
8+
9+
The source code is located in the `src` directory, and the project follows the PSR-4 autoloading standard.
10+
11+
## 2. Development Environment
12+
13+
The project uses Composer to manage dependencies. These dependencies are installed automatically when using the Docker development environment.
14+
15+
## 3. Build, Lint, and Test Commands
16+
17+
The following commands are used to ensure code quality and correctness.
18+
19+
### 3.1. Testing (PHPUnit)
20+
21+
The project uses PHPUnit for unit and feature testing.
22+
23+
- **Run all tests:**
24+
```bash
25+
docker compose run --rm tests
26+
```
27+
28+
- **Run a single test file:**
29+
To run a specific test file, provide the path to the file.
30+
```bash
31+
docker compose run --rm tests tests/Unit/ImageManagerTest.php
32+
```
33+
34+
- **Run a single test method:**
35+
Use the `--filter` option to run a specific test method by its name.
36+
```bash
37+
docker compose run --rm tests tests/Unit/ImageManagerTest.php --filter testMethodName
38+
```
39+
40+
- **Check test coverage:**
41+
```bash
42+
docker compose run --rm coverage
43+
```
44+
45+
### 3.2. Static Analysis (PHPStan)
46+
47+
PHPStan is used for static analysis to find potential bugs.
48+
49+
- **Run static analysis:**
50+
```bash
51+
docker compose run --rm analysis
52+
```
53+
54+
### 3.3. Coding Standards (PHP CodeSniffer)
55+
56+
The project adheres to the PSR-12 coding standard with additional rules. PHP CodeSniffer is used to enforce these standards.
57+
58+
- **Check for coding standard violations:**
59+
```bash
60+
docker compose run --rm standards
61+
```
62+
63+
## 4. Code Style and Conventions
64+
65+
Consistency is key. Adhere to the following guidelines when writing code.
66+
67+
### 4.1. Formatting
68+
69+
- **PSR-12:** The primary coding standard is PSR-12.
70+
- **Indentation:** Use 4 spaces for indentation, not tabs.
71+
- **Line Endings:** Use Unix-style line endings (LF).
72+
- **Strict Types:** All PHP files must start with `declare(strict_types=1);`.
73+
- **Class Structure:** Follow the ordering defined in `phpcs.xml.dist`:
74+
1. `uses`
75+
2. `enum cases`
76+
3. `constants`
77+
4. `static properties`
78+
5. `properties`
79+
6. `constructor`
80+
7. `static constructors`
81+
8. `methods`
82+
9. `magic methods`
83+
84+
### 4.2. Naming Conventions
85+
86+
- **Classes:** `PascalCase`.
87+
- **Methods:** `camelCase`.
88+
- **Variables:** `camelCase`.
89+
- **Constants:** `UPPER_CASE` with underscore separators.
90+
- **File Names:** File names must match the class name they contain (e.g., `MyClass.php` for `class MyClass`).
91+
92+
### 4.3. Imports
93+
94+
- **One class per `use` statement:** Do not group multiple classes in a single `use` statement.
95+
- **No leading backslash:** `use` statements must not start with a backslash.
96+
- **Order:** `use` statements should be ordered alphabetically. Unused imports must be removed.
97+
98+
### 4.4. Types and Type Hinting
99+
100+
- **Strict Typing:** All code should be strictly typed.
101+
- **Parameter Types:** All method parameters must have a type hint.
102+
- **Return Types:** All methods must have a return type hint.
103+
- **Property Types:** All class properties must have a type hint.
104+
- **Nullable Types:** Use nullable types (`?TypeName`) when a `null` value is explicitly allowed.
105+
106+
### 4.5. Error Handling
107+
108+
- Exceptions should be used for error handling.
109+
- When catching exceptions, be as specific as possible. Avoid catching generic `\Exception` or `\Throwable`.
110+
- Exception messages should be clear and descriptive.
111+
112+
### 4.6. PHPDoc (DocBlocks)
113+
114+
- PHPDoc blocks are required for all classes, properties, and methods.
115+
- Follow the annotation order defined in `phpcs.xml.dist`.
116+
- Use DocBlocks to provide context and explain complex logic. Do not restate the obvious from the code signature.
117+
118+
## 5. Branching and Commits
119+
120+
- **Branching:** Create new branches from the `develop` branch. Name branches descriptively (e.g., `feature/new-filter`, `bugfix/fix-resize-issue`).
121+
- **Commits:** Write clear and concise commit messages. The first line should be a short summary (max 50 chars). A more detailed explanation can follow after a blank line. Always write the message in imperative and do NOT use any useless prefixes like "chore" or other.
122+
- **Pull Requests:** Target the `develop` branch for all pull requests. Ensure all checks (tests, linting, analysis) are passing before submitting.

Dockerfile

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,53 @@
1-
FROM php:8.1-cli
1+
FROM php:8.3-cli
22

3-
# install dependencies
3+
ARG IMAGEMAGICK_VERSION=7.1.2-15
4+
5+
# install dependencies for building ImageMagick and PHP extensions
46
RUN apt update \
57
&& apt install -y \
6-
libmagickwand-dev \
7-
libwebp-dev \
8+
libjpeg-dev \
9+
libgif-dev \
10+
libtiff-dev \
811
libpng-dev \
12+
libwebp-dev \
913
libavif-dev \
14+
libheif-dev \
15+
libraqm-dev \
16+
libopenjp2-7-dev \
17+
liblcms2-dev \
1018
git \
1119
zip \
12-
&& pecl install imagick \
20+
curl \
21+
xz-utils \
22+
&& apt-get clean
23+
24+
# build and install ImageMagick from source
25+
RUN curl -o /tmp/ImageMagick.tar.xz -sL \
26+
"https://imagemagick.org/archive/releases/ImageMagick-${IMAGEMAGICK_VERSION}.tar.xz" \
27+
&& cd /tmp \
28+
&& tar xf ImageMagick.tar.xz \
29+
&& cd "ImageMagick-${IMAGEMAGICK_VERSION}" \
30+
&& ./configure \
31+
&& make -j$(nproc) \
32+
&& make install \
33+
&& ldconfig \
34+
&& cd / \
35+
&& rm -rf /tmp/ImageMagick*
36+
37+
# install PHP extensions
38+
RUN pecl install imagick \
1339
&& pecl install xdebug \
1440
&& docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp --with-avif \
1541
&& docker-php-ext-enable \
1642
imagick \
1743
xdebug \
1844
&& docker-php-ext-install \
1945
gd \
20-
exif \
21-
&& apt-get clean
46+
exif
2247

2348
# install composer
2449
COPY --from=composer /usr/bin/composer /usr/bin/composer
2550

26-
# install composer dependencies
27-
COPY composer.json composer.lock ./
28-
RUN composer install
51+
# setup entrypoint
52+
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
53+
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
}
2020
],
2121
"require": {
22-
"php": "^8.1",
22+
"php": "^8.3",
2323
"ext-mbstring": "*",
24-
"intervention/gif": "^4.2"
24+
"intervention/gif": "^5"
2525
},
2626
"require-dev": {
27-
"phpunit/phpunit": "^10.0 || ^11.0 || ^12.0",
27+
"phpunit/phpunit": "^12.0",
2828
"mockery/mockery": "^1.6",
2929
"phpstan/phpstan": "^2.1",
3030
"squizlabs/php_codesniffer": "^4",

docker-compose.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@ services:
22
tests:
33
build: ./
44
working_dir: /project
5-
entrypoint: ["./vendor/bin/phpunit"]
5+
entrypoint: ["/usr/local/bin/entrypoint.sh", "./vendor/bin/phpunit"]
66
volumes:
77
- ./:/project
88
coverage:
99
build: ./
1010
working_dir: /project
11-
entrypoint: ["./vendor/bin/phpunit", "--coverage-text"]
11+
entrypoint: ["/usr/local/bin/entrypoint.sh", "./vendor/bin/phpunit", "--coverage-text"]
1212
volumes:
1313
- ./:/project
1414
environment:
1515
- XDEBUG_MODE=coverage
1616
analysis:
1717
build: ./
1818
working_dir: /project
19-
entrypoint: ["./vendor/bin/phpstan", "analyze", "--memory-limit=512M"]
19+
entrypoint: ["/usr/local/bin/entrypoint.sh", "./vendor/bin/phpstan", "analyze", "--memory-limit=512M"]
2020
volumes:
2121
- ./:/project
2222
standards:
2323
build: ./
2424
working_dir: /project
25-
entrypoint: ["./vendor/bin/phpcs"]
25+
entrypoint: ["/usr/local/bin/entrypoint.sh", "./vendor/bin/phpcs"]
2626
volumes:
2727
- ./:/project

entrypoint.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
set -e
3+
4+
composer install --quiet
5+
6+
exec "$@"

phpstan.dist.neon

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,3 @@ parameters:
22
level: 6
33
paths:
44
- src
5-
reportUnmatchedIgnoredErrors: false
6-
ignoreErrors:
7-
-
8-
identifier: unset.possiblyHookedProperty
9-
exceptions:
10-
check:
11-
missingCheckedExceptionInThrows: true
12-
uncheckedExceptionClasses:
13-
- ImagickException
14-
- ImagickDrawException
15-
- ImagickPixelException
16-
- Error

phpunit.dist.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
cacheDirectory=".phpunit.cache"
1010
colors="true"
1111
displayDetailsOnTestsThatTriggerNotices="true"
12+
displayDetailsOnTestsThatTriggerDeprecations="true"
13+
displayDetailsOnPhpunitDeprecations="true"
14+
displayDetailsOnTestsThatTriggerWarnings="true"
1215
processIsolation="false"
1316
stopOnFailure="false">
1417
<testsuites>

readme.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,51 +8,51 @@
88

99
Intervention Image is a **PHP image processing library** that provides a simple
1010
and expressive way to create, edit, and compose images. It comes with a universal
11-
interface for the two most popular PHP image manipulation extensions. You can
12-
choose between the GD library or Imagick as the base layer for all operations.
11+
interface for the popular PHP image manipulation extensions. You can
12+
choose between the GD library, Imagick or libvips as the base layer for all operations.
1313

14-
- Simple interface for common image editing tasks
15-
- Interchangeable driver architecture
16-
- Support for animated images
14+
- Fluent interface for common image editing tasks
15+
- Interchangeable driver architecture with support for **GD, Imagick and libvips**
16+
- Support for animated images with all drivers
1717
- Framework-agnostic
18-
- PSR-12 compliant
1918

2019
## Installation
2120

22-
You can easily install this library using [Composer](https://getcomposer.org).
23-
Simply request the package with the following command:
21+
Install this library using [Composer](https://getcomposer.org). Simply request the package with the following command:
2422

2523
```bash
2624
composer require intervention/image
2725
```
2826

2927
## Getting Started
3028

31-
Learn the [basics](https://image.intervention.io/v3/basics/instantiation/) on
32-
how to use Intervention Image and more with the [official
33-
documentation](https://image.intervention.io/v3/).
29+
Learn the [basics](https://image.intervention.io/v4/basics/instantiation/) on
30+
how to use Intervention Image and more with the [official documentation](https://image.intervention.io/v4/).
3431

3532
## Code Examples
3633

3734
```php
3835
use Intervention\Image\ImageManager;
36+
use Intervention\Image\Drivers\Gd\Driver as GdDriver;
37+
use Intervention\Image\Alignment;
38+
use Intervention\Image\Color;
39+
use Intervention\Image\Format;
40+
use Intervention\Image\Fraction;
3941

40-
// create image manager with desired driver
41-
$manager = new ImageManager(
42-
new Intervention\Image\Drivers\Gd\Driver()
43-
);
42+
// create image manager instance using the preferred driver
43+
$manager = ImageManager::usingDriver(GdDriver::class);
4444

45-
// open an image file
46-
$image = $manager->read('images/example.gif');
45+
// read image data from path
46+
$image = $manager->decodePath('images/example.webp');
4747

48-
// resize image instance
49-
$image->resize(height: 300);
48+
// scale image by height
49+
$image->scale(height: 300);
5050

5151
// insert a watermark
52-
$image->place('images/watermark.png');
52+
$image->insert('images/watermark.png', alignment: Alignment::BOTTOM_RIGHT);
5353

5454
// encode edited image
55-
$encoded = $image->toJpg();
55+
$encoded = $image->encodeUsingFormat(Format::JPEG, quality: 65);
5656

5757
// save encoded image
5858
$encoded->save('images/example.jpg');
@@ -63,9 +63,9 @@ $encoded->save('images/example.jpg');
6363
Before you begin with the installation make sure that your server environment
6464
supports the following requirements.
6565

66-
- PHP >= 8.1
66+
- PHP >= 8.3
6767
- Mbstring PHP Extension
68-
- Image Processing PHP Extension
68+
- Image Processing PHP Extension (GD, Imagick or libvips)
6969

7070
## Supported Image Libraries
7171

0 commit comments

Comments
 (0)