@@ -319,10 +319,14 @@ public function testMoreText(): void
319319
320320 public function testImageCreation (): void
321321 {
322- foreach (['gif ' , 'jpeg ' , 'png ' , 'webp ' ] as $ type ) {
322+ foreach (['gif ' , 'jpeg ' , 'png ' , 'webp ' , ' avif ' ] as $ type ) {
323323 if ($ type === 'webp ' && ! function_exists ('imagecreatefromwebp ' )) {
324324 $ this ->expectException (ImageException::class);
325- $ this ->expectExceptionMessage ('Your server does not support the GD function required to process this type of image. ' );
325+ $ this ->expectExceptionMessage ('Your server does not support the GD function required to process a webp image. ' );
326+ }
327+ if ($ type === 'avif ' && ! function_exists ('imagecreatefromavif ' )) {
328+ $ this ->expectException (ImageException::class);
329+ $ this ->expectExceptionMessage ('Your server does not support the GD function required to process an avif image. ' );
326330 }
327331
328332 $ this ->handler ->withFile ($ this ->origin . 'ci-logo. ' . $ type );
@@ -334,10 +338,14 @@ public function testImageCreation(): void
334338
335339 public function testImageCopy (): void
336340 {
337- foreach (['gif ' , 'jpeg ' , 'png ' , 'webp ' ] as $ type ) {
341+ foreach (['gif ' , 'jpeg ' , 'png ' , 'webp ' , ' avif ' ] as $ type ) {
338342 if ($ type === 'webp ' && ! function_exists ('imagecreatefromwebp ' )) {
339343 $ this ->expectException (ImageException::class);
340- $ this ->expectExceptionMessage ('Your server does not support the GD function required to process this type of image. ' );
344+ $ this ->expectExceptionMessage ('Your server does not support the GD function required to process a webp image. ' );
345+ }
346+ if ($ type === 'avif ' && ! function_exists ('imagecreatefromavif ' )) {
347+ $ this ->expectException (ImageException::class);
348+ $ this ->expectExceptionMessage ('Your server does not support the GD function required to process an avif image. ' );
341349 }
342350
343351 $ this ->handler ->withFile ($ this ->origin . 'ci-logo. ' . $ type );
@@ -353,9 +361,13 @@ public function testImageCopy(): void
353361
354362 public function testImageCopyWithNoTargetAndMaxQuality (): void
355363 {
356- foreach (['gif ' , 'jpeg ' , 'png ' , 'webp ' ] as $ type ) {
364+ foreach (['gif ' , 'jpeg ' , 'png ' , 'webp ' , ' avif ' ] as $ type ) {
357365 $ this ->handler ->withFile ($ this ->origin . 'ci-logo. ' . $ type );
358- $ this ->handler ->save (null , 100 );
366+ if ($ type === 'avif ' ) {
367+ $ this ->handler ->save (null , 100 , 10 );
368+ } else {
369+ $ this ->handler ->save (null , 100 );
370+ }
359371 $ this ->assertFileExists ($ this ->origin . 'ci-logo. ' . $ type );
360372
361373 $ this ->assertSame (
@@ -367,10 +379,14 @@ public function testImageCopyWithNoTargetAndMaxQuality(): void
367379
368380 public function testImageCompressionGetResource (): void
369381 {
370- foreach (['gif ' , 'jpeg ' , 'png ' , 'webp ' ] as $ type ) {
382+ foreach (['gif ' , 'jpeg ' , 'png ' , 'webp ' , ' avif ' ] as $ type ) {
371383 if ($ type === 'webp ' && ! function_exists ('imagecreatefromwebp ' )) {
372384 $ this ->expectException (ImageException::class);
373- $ this ->expectExceptionMessage ('Your server does not support the GD function required to process this type of image. ' );
385+ $ this ->expectExceptionMessage ('Your server does not support the GD function required to process a webp image. ' );
386+ }
387+ if ($ type === 'avif ' && ! function_exists ('imagecreatefromavif ' )) {
388+ $ this ->expectException (ImageException::class);
389+ $ this ->expectExceptionMessage ('Your server does not support the GD function required to process an avif image. ' );
374390 }
375391
376392 $ this ->handler ->withFile ($ this ->origin . 'ci-logo. ' . $ type );
@@ -387,10 +403,14 @@ public function testImageCompressionGetResource(): void
387403
388404 public function testImageCompressionWithResource (): void
389405 {
390- foreach (['gif ' , 'jpeg ' , 'png ' , 'webp ' ] as $ type ) {
406+ foreach (['gif ' , 'jpeg ' , 'png ' , 'webp ' , ' avif ' ] as $ type ) {
391407 if ($ type === 'webp ' && ! function_exists ('imagecreatefromwebp ' )) {
392408 $ this ->expectException (ImageException::class);
393- $ this ->expectExceptionMessage ('Your server does not support the GD function required to process this type of image. ' );
409+ $ this ->expectExceptionMessage ('Your server does not support the GD function required to process a webp image. ' );
410+ }
411+ if ($ type === 'avif ' && ! function_exists ('imagecreatefromavif ' )) {
412+ $ this ->expectException (ImageException::class);
413+ $ this ->expectExceptionMessage ('Your server does not support the GD function required to process an avif image. ' );
394414 }
395415
396416 $ this ->handler ->withFile ($ this ->origin . 'ci-logo. ' . $ type )
@@ -423,6 +443,15 @@ public function testImageConvertPngToWebp(): void
423443 $ this ->assertSame (IMAGETYPE_WEBP , exif_imagetype ($ saved ));
424444 }
425445
446+ public function testImageConvertPngToAvif (): void
447+ {
448+ $ this ->handler ->withFile ($ this ->origin . 'rocket.png ' );
449+ $ this ->handler ->convert (IMAGETYPE_AVIF );
450+ $ saved = $ this ->start . 'work/rocket.avif ' ;
451+ $ this ->handler ->save ($ saved );
452+ $ this ->assertSame (IMAGETYPE_AVIF , exif_imagetype ($ saved ));
453+ }
454+
426455 public function testImageReorientLandscape (): void
427456 {
428457 for ($ i = 0 ; $ i <= 8 ; $ i ++) {
0 commit comments