Skip to content

Commit 4b04f2c

Browse files
committed
wip
1 parent 1004da9 commit 4b04f2c

3 files changed

Lines changed: 22 additions & 10 deletions

File tree

.github/workflows/reusable-phpunit-test.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,6 @@ jobs:
167167
sudo apt-get update
168168
sudo apt-get install -y imagemagick libmagickwand-dev ghostscript poppler-data libjbig2dec0:amd64 libopenjp2-7:amd64 libheif-dev libmagickcore-6.q16-7-extra
169169
170-
- name: Check ImageMagick AVIF support
171-
if: ${{ contains(inputs.extra-extensions, 'imagick') }}
172-
run: |
173-
convert -list delegate | grep -i "heic\|avif" || echo "No HEIC/AVIF delegate found"
174-
apt-cache show imagemagick | grep -i "version"
175-
apt-cache search "magickcore.*extra"
176-
177170
- name: Checkout base branch for PR
178171
if: github.event_name == 'pull_request'
179172
uses: actions/checkout@v6

system/Images/Handlers/ImageMagickHandler.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,20 @@ public function save(?string $target = null, int $quality = 90): bool
384384
try {
385385
$result = $this->resource->writeImage($target);
386386

387+
if (! $result || ! file_exists($target) || filesize($target) === 0) {
388+
$extension = strtoupper(pathinfo($target, PATHINFO_EXTENSION));
389+
$message = match ($extension) {
390+
'GIF' => lang('Images.gifNotSupported'),
391+
'JPG', 'JPEG' => lang('Images.jpgNotSupported'),
392+
'PNG' => lang('Images.pngNotSupported'),
393+
'WEBP' => lang('Images.webpNotSupported'),
394+
'AVIF' => lang('Images.avifNotSupported'),
395+
default => null,
396+
};
397+
398+
throw ImageException::forInvalidImageCreate($message);
399+
}
400+
387401
chmod($target, $this->filePermissions);
388402

389403
$this->resource->clear();

tests/system/Images/ImageMagickHandlerTest.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,9 +434,14 @@ public function testImageConvertPngToWebp(): void
434434

435435
public function testImageConvertPngToAvif(): void
436436
{
437-
$this->handler->withFile($this->origin . 'ci-logo.png');
438-
$this->handler->convert(IMAGETYPE_AVIF);
439-
$this->handler->save($this->root . 'ci-logo.avif');
437+
try {
438+
$this->handler->withFile($this->origin . 'ci-logo.png');
439+
$this->handler->convert(IMAGETYPE_AVIF);
440+
$this->handler->save($this->root . 'ci-logo.avif');
441+
} catch (ImageException $e) {
442+
$this->markTestSkipped('AVIF encoding is not supported on this system: ' . $e->getMessage());
443+
}
444+
440445
$this->assertSame(IMAGETYPE_AVIF, exif_imagetype($this->root . 'ci-logo.avif'));
441446
}
442447

0 commit comments

Comments
 (0)