Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x]: Conversion of image to AVIF failing #15697

Closed
petehjfd opened this issue Sep 9, 2024 · 6 comments
Closed

[5.x]: Conversion of image to AVIF failing #15697

petehjfd opened this issue Sep 9, 2024 · 6 comments
Assignees
Labels

Comments

@petehjfd
Copy link

petehjfd commented Sep 9, 2024

What happened?

Description

We are using image transforms to convert JPEGs to AVIFs. This works fine locally in ddev, but fails on our (managed VPS) live server.

In the browser, we get the folliwing error:

Internal Server Error

Failed to generate transform with id of 251.

In the log file, we get:

2024-09-06 08:21:49 [web.ERROR] [craft\errors\ImageTransformException] Failed to generate transform with id of 622. {"trace":["#0 /home/***********************/vendor/craftcms/cms/src/controllers/AssetsController.php(1131): craft\\imagetransforms\\ImageTransformer->getTransformUrl()","#1 [internal function]: craft\\controllers\\AssetsController->actionGenerateTransform()","#2 /home/***********************/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()","#3 /home/***********************/vendor/yiisoft/yii2/base/Controller.php(178): yii\\base\\InlineAction->runWithParams()","#4 /home/***********************/vendor/yiisoft/yii2/base/Module.php(552): yii\\base\\Controller->runAction()","#5 /home/***********************/vendor/craftcms/cms/src/web/Application.php(349): yii\\base\\Module->runAction()","#6 /home/***********************/vendor/craftcms/cms/src/web/Application.php(648): craft\\web\\Application->runAction()","#7 /home/***********************/vendor/craftcms/cms/src/web/Application.php(311): craft\\web\\Application->_processActionRequest()","#8 /home/***********************/vendor/yiisoft/yii2/base/Application.php(384): craft\\web\\Application->handleRequest()","#9 /home/***********************/web/index.php(12): yii\\base\\Application->run()","#10 {main}"],"memory":21822144,"exception":"[object] (craft\\errors\\ImageTransformException(code: 0): Failed to generate transform with id of 622. at /home/***********************/vendor/craftcms/cms/src/imagetransforms/ImageTransformer.php:153)\n[previous exception] [object] (craft\\errors\\ImageException(code: 2): Failed to save the image. at /home/***********************/vendor/craftcms/cms/src/image/Raster.php:584)\n[previous exception] [object] (Imagine\\Exception\\RuntimeException(code: 2): imageavif(): AVIF image support has been disabled\n at /home/***********************/vendor/pixelandtonic/imagine/src/Utils/ErrorHandling.php:73)\n[previous exception] [object] (ErrorException(code: 0): imageavif(): AVIF image support has been disabled\n at /home/***********************/vendor/pixelandtonic/imagine/src/Gd/Image.php:648)"} 

phpinfo confirms that AVIF support is enabled and we have installed libheif-dev along with libjpeg-dev, libpng-dev and libwebp-dev on the server.

We put the following test code in a PHP file in the web root and it works perfectly (the AVIF image is created).

$image = imagecreatefromjpeg('example.jpg');
imageavif($image, 'example.avif');

The fact that AVIF generation works on the server outside of Craft suggests that this is a Craft-specific issue?

PHP 8.2.5
Image driver: GD 8.2.5

Craft CMS version

5.3.6

PHP version

8.2.5

Operating system and version

Ubuntu 18.04.6 LTS

Database type and version

MariaDB

Image driver and version

GD 8.2.5

Installed plugins and versions

Amazon S3 2.2.1
Blitz 5.7.1
Bugsnag 5.0.0
CKEditor 4.2.0
Dashboard Begone 3.0.0
Element API 4.1.0
Navigation 3.0.3
oEmbed 3.0.9
SEOmatic 5.1.2
Sprig 3.5.0
Wordsmith 5.0.0

@petehjfd petehjfd added the bug label Sep 9, 2024
@brandonkelly
Copy link
Member

Please search through storage/logs for Failed to generate transform with id of.

You should be able to find an exception logged that also includes the previous exception. When you find it, please post the full log details.

@petehjfd
Copy link
Author

Hi @brandonkelly - that's already included above, where I say "In the log file, we get:". Unless you need more than that?

Thanks

@brandonkelly
Copy link
Member

Sorry, I missed that the previous exception was included in that.

Here’s the underlying error, pulled from that:

imageavif(): AVIF image support has been disabled

That’s coming straight from PHP. I’m not sure why there’s a discrepancy between that and what phpinfo() is telling you, though. Are you calling phpinfo() in your own script, or checking Utilities → PHP Info in the control panel?

@petehjfd
Copy link
Author

I've tried both phpinfo() in my own script and in Utilities. They both say AVIF support is enabled.

Thanks

@angrybrad
Copy link
Member

If you var_dump(gd_info());, do you see AVIF support enabled?

Curios if you swap to Imagick, do you get different behavior?

@angrybrad angrybrad self-assigned this Sep 14, 2024
@petehjfd
Copy link
Author

var_dump(gd_info()); shows AVIF as enabled.

As this is managed hosting, we can't easily install Imagick I'm afraid.

We've actually decided to move the site in question over to different (VPS) hosting and will be gradully migrating the rest of our sites. So this is no longer a pressing issue for us. If you've had no other reports of this issue, I'd be happy for the issue to be closed.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants