webP errors

12 posts by 3 authors in: Forums > CMS Builder
Last Post: November 30, 2021   (RSS)

By rez - November 13, 2021

Trying the latest version.  Is this a server issue or...

Unable to set image format
in /home/mong/public_html/cmsb/lib/image_functions.php on line 401. Call to undefined function imagecreatefromwebp()
in /home/mong/public_html/cmsb/lib/image_functions.php on line 40. Unable to set image format
in /home/mong/public_html/cmsb/lib/image_functions.php on line 401. Unable to set image format
in /home/mong/public_html/cmsb/lib/image_functions.php on line 401.

By rez - November 13, 2021

Oh no... I unchecked the webP option and I am still getting the error as if CMSB is still trying to convert. 

I can't upload any photos.

Call to undefined function imagecreatefromwebp()
in /home/mong/public_html/cmsb/lib/image_functions.php on line 40.

By rez - November 13, 2021 - edited: November 13, 2021

Update: although I had the option to convert to WebP turned back off, I still had webP as an upload option and was trying to upload a webP image.

I removed that file type from the upload filed possibilities and uploading jps are working.

I am not converting and I'm not sure if I am supposed to be able to at least upload and use webP? I would think so. This is the first time I have tried.

Please advise.

...unless it was still trying to convert because of a cache situation. I need this site done tonight so no more experimenting from me for now! 

By pault - November 24, 2021

Hi Michael,

I'm also getting this error.  I'm trying to upload a jpg image with the option to 'Automatically convert image uploads to WebP format' selected.

I've checked phpinfo() and get the same as your screenshot, WebP support is enabled.

OS is CentOS 7.9.2009, PHP is v8.0.13.

Regards, Paul.

Hi Paul,

I have 2 quick troubleshooting steps for you to try.

#1 Create a new PHP file with the following code, upload it, and run it on your site.

<?php

if(function_exists('imagecreatefromwebp')) {
  echo 'imagecreatefromwebp() is available';
} else {
  echo 'imagecreatefromwebp() is NOT available';
}

?>

#2 Create a new section editor with an upload field, but uncheck all of the resize/thumbnail options.  Make sure the Use WebP option is enabled in the General Settings.  Then try to upload a JPG file in that editor.  We just want the JPG file to be uploaded and converted.  I want to see if the problem is specific to the imagecreatefromwebp() function or if none of the webp-related functions are working.

Thanks

Michael Sams
Programmer
interactivetools.com

By pault - November 29, 2021

Hi Michael,

Thanks for your reply.

So the first point returns 'imagecreatefromwebp() is available'

I've created the section with upload field, unchecked all of the options and ensured WebP is turned on and get the same error message as before:

Unable to set image format
in httpdocs/cmsAdmin/lib/image_functions.php on line 401.

Regards, Paul.

Hi Paul,

Can you check the Imagick section on the phpinfo() output to see if WebP is listed there?  I've attached a sample output of what we're looking for here.

Thanks,

Michael

Michael Sams
Programmer
interactivetools.com

By pault - November 29, 2021

Hi Michael,

WEBP isn't listed there.  Is it possible to get CMS Builder to use GD instead of ImageMagick?  Or do you think there's another workaround?

Thanks, Paul.

Hi Paul,

In your particular case it looks like ImageMagick is not configured with WebP support.

I would start by requesting that your hosting provider add WebP support to the ImageMagick configuration on your server.

We will be releasing a patch/update to check for this scenario but in the mean time if you're comfortable editing CMSB's files you can patch this issue yourself very easily following the steps below.

  1. Save a backup copy of the /lib/image_functions.php file.
  2. Open the /lib/image_functions.php file in a text editor or your favorite IDE.
  3. Search for this line (around line #394):
    if(extension_loaded('imagick') and $extension != 'gd') {​
  4. Replace that line with this:
    if(extension_loaded('imagick') and $extension != 'gd' and in_array('WEBP', \Imagick::queryformats())) {​

This will add an additional check for WebP support specifically and in your case should result in the script falling back to using the GD library to handle the conversion.

Thanks,

Michael

Michael Sams
Programmer
interactivetools.com