Question regarding limitations of WebP function in CMSB
So my client may have stumpled upon an issue with the automated webp converter. He kept getting an error on larger files BUT he WAS having some Internet speed issues so I explained that during uploads, if the connection halts for a moment or can't handle the number of packets running through then that could easily cause a problem during uploads. However, he took my advice and tried uploading from two separate distinct locations...30miles and different ISPs. He kept running into the same problem. So I ran some tests. He is correct. I've narrowed down the issue quite a bit.
The system errors on the uploads when uploading .png files somewhere between 10-20 mb file size. I realize that's larger than 'normal' but we have some specific use cases. If I turn the automatic webp converter off (uncheck the box) then the same files that failed had no problem uploading and showing. So the challenge seems to be with larger file sizes that are being converted to webp. It may be the package the hosting company is utilizing or it may be that the webp converter simply can't handle files that large.
Does any one here have experience using the upload webp converter on larger files? Or come across similar issue? Thanks.
There are a number of reasons the conversion could fail when using such large image sizes, though I have confirmed that it's possible to convert a 25MB PNG to webp - it just required updating some server settings. A few potential causes are:
- Reaching memory limit - image operations can take a high amount of memory. This is governed by the "memory_limit" PHP setting.
- Script timeout - the conversion can take longer for large files (on my test server, the 25MB PNG converted in ~8 seconds). This is governed by the "max_execution_time" PHP setting, as well as the server's speed.
In addition to looking into the above settings, you can also see if it's possible to enable the Imagick PHP extension on the server. Generally, Imagick is faster and more memory-efficient when doing image operations than the built-in PHP functions, so this may also help with some of these limitations.
Let me know if you have any other questions!
The web host documentation states the following with regards to Imagick and Image Magick:
By default, ImageMagick is installed on InMotion Hosting servers. However, it can only be accessed through the command line, a cron job or PHP code on a web page. The path for the command line options would look like this:
ImageMagick has many modules that can be loaded, but for the purposes of InMotion’s hosting servers, the main commands available are
mogrify. These commands can be used through PHP using a native extension called Imagick. For more information, please see the Imagick class in the PHP documentation.
If I click on the link to the Imagick class it basically lists out a very long section of php documentation. So my question is: Since this documentation states that Imagick has to "be accessed through the comman line, a cron job or PHP code on a web page" -- is there something 'else' that needs to occur for it to automatically run/work with the CMSB webp conversions? Or is it already taken care of?
In that case, the PHP module for Imagick does not appear to be enabled. This is something that would need to be done on the server by the host, though not all hosts will support it.
Have you looked into the memory_limit and max_execution_time settings? You can find the current values for both of these settings on the General Settings page in CMSB, under Admin Menu.
I have access to WHM-root so I can enable/disable the imagik extension. I did so earlier but ran into the same issues...when I reviewed the error it was definitely related to exceeding the memory limit on the test uploads. I disabled it and then your reply came in :-)
Here are the details from the CMSB settings section. Could you tell me what numbers, specifically, would work better (provided I can change them)?
max cpu seconds: unlimited
ulimit memory limit: unlimited
Thank you kindly!
When testing locally using gd and a 30MB PNG, it works with a memory_limit of 512MB, so I'd suggest trying that out. You can change it in /cmsb/lib/init.php - there should be a line like this:
You can change this to whatever value you need. Note that this value will be overwritten during CMS upgrades, so you should make a note of the change.
Your max_execution_time is 6 minutes which generally should be fine, though if the process hangs for exactly 6 minutes that could be a clue.
Let me know if this helps!