@@ -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,12 @@ 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 );
359370 $ this ->assertFileExists ($ this ->origin . 'ci-logo. ' . $ type );
360371
361372 $ this ->assertSame (
@@ -367,10 +378,14 @@ public function testImageCopyWithNoTargetAndMaxQuality(): void
367378
368379 public function testImageCompressionGetResource (): void
369380 {
370- foreach (['gif ' , 'jpeg ' , 'png ' , 'webp ' ] as $ type ) {
381+ foreach (['gif ' , 'jpeg ' , 'png ' , 'webp ' , ' avif ' ] as $ type ) {
371382 if ($ type === 'webp ' && ! function_exists ('imagecreatefromwebp ' )) {
372383 $ this ->expectException (ImageException::class);
373- $ this ->expectExceptionMessage ('Your server does not support the GD function required to process this type of image. ' );
384+ $ this ->expectExceptionMessage ('Your server does not support the GD function required to process a webp image. ' );
385+ }
386+ if ($ type === 'avif ' && ! function_exists ('imagecreatefromavif ' )) {
387+ $ this ->expectException (ImageException::class);
388+ $ this ->expectExceptionMessage ('Your server does not support the GD function required to process an avif image. ' );
374389 }
375390
376391 $ this ->handler ->withFile ($ this ->origin . 'ci-logo. ' . $ type );
@@ -387,10 +402,14 @@ public function testImageCompressionGetResource(): void
387402
388403 public function testImageCompressionWithResource (): void
389404 {
390- foreach (['gif ' , 'jpeg ' , 'png ' , 'webp ' ] as $ type ) {
405+ foreach (['gif ' , 'jpeg ' , 'png ' , 'webp ' , ' avif ' ] as $ type ) {
391406 if ($ type === 'webp ' && ! function_exists ('imagecreatefromwebp ' )) {
392407 $ this ->expectException (ImageException::class);
393- $ this ->expectExceptionMessage ('Your server does not support the GD function required to process this type of image. ' );
408+ $ this ->expectExceptionMessage ('Your server does not support the GD function required to process a webp image. ' );
409+ }
410+ if ($ type === 'avif ' && ! function_exists ('imagecreatefromavif ' )) {
411+ $ this ->expectException (ImageException::class);
412+ $ this ->expectExceptionMessage ('Your server does not support the GD function required to process an avif image. ' );
394413 }
395414
396415 $ this ->handler ->withFile ($ this ->origin . 'ci-logo. ' . $ type )
@@ -423,6 +442,15 @@ public function testImageConvertPngToWebp(): void
423442 $ this ->assertSame (IMAGETYPE_WEBP , exif_imagetype ($ saved ));
424443 }
425444
445+ public function testImageConvertPngToAvif (): void
446+ {
447+ $ this ->handler ->withFile ($ this ->origin . 'rocket.png ' );
448+ $ this ->handler ->convert (IMAGETYPE_AVIF );
449+ $ saved = $ this ->start . 'work/rocket.avif ' ;
450+ $ this ->handler ->save ($ saved );
451+ $ this ->assertSame (IMAGETYPE_AVIF , exif_imagetype ($ saved ));
452+ }
453+
426454 public function testImageReorientLandscape (): void
427455 {
428456 for ($ i = 0 ; $ i <= 8 ; $ i ++) {
0 commit comments