Содержание
- How to Enable WebP support Php 7 without Recompiling?
- What is WebP & Why its Important?
- Does All Browser Support WebP Format Images?
- How to enable WebP support in PHP 7.x or Any Version?
- How can I Enable Webp support in php GD library in xampp on linux? #254
- Comments
- Add WebP support to GD (PHP Module)
- BoxMan
- cPanelMichael
- BoxMan
- JacobPerkins
- BoxMan
- cPanelMichael
- BoxMan
- SunHunter
- Внедряем поддержку формата изображений WebP
- Не поддерживаетя функция ImageCreateFromJpeg()
- shtogrin
- shtogrin
- shtogrin
- tony2001
- tony2001
- shtogrin
How to Enable WebP support Php 7 without Recompiling?
Today, I came across a problem when I have shifted my websites to a new server having PHP 7 installed. One of my websites uses PHP imagewebp() function to generate WebP images. I was using centos 7.x server with Nginx installed and PHP version was 7.0. When I was trying to generate WebP images, I was getting error fatal error: Uncaught Error: Call to undefined function imagewebp(). I searched google and tried various tutorials in order to solve this issue, but all in vain. After trying several hours, I found the alternate solution to generate WebP images without recompiling PHP and without installing any package. Also, this method doesn’t require root access to the server. So, read this tutorial to know, how to enable WebP support in GD library for PHP 7 in CentOS Nginx.
What is WebP & Why its Important?
WebP format of the image was developed by Google. The reason behind it was to make small size images with lossless compression in order to make web pages smaller and serve them fast. WebP format is the successor to jpeg format.
According to Google: WebP is a modern image format which provides superior lossless and lossy compression for images. Using WebP, web developers can create smaller, richer images that make the web faster.
Now it’s clear that Google is forcing web developers to serve WebP images in order to make web pages much faster. WebP images are 26% smaller in size compared to png, 25-34% smaller than jpeg images. In short, WebP images are approximately 3 times smaller than other formats.
Does All Browser Support WebP Format Images?
No, all browser do not support WebP format images. WebP was created google and it is supported by google official Chrome web browser and other browsers like Microsoft Edge, Firefox & Opera. However, it is not supported by some of the major browsers like Safari.
But there’s a method to serve images according to browser compatibility. For this, we need to write a bit of HTML code. Here’s the HTML code below:
Using the above code, we can serve the supported image format to browser depending on the compatibility of WebP format.
How to enable WebP support in PHP 7.x or Any Version?
As I wrote above, I tried to enable WebP support using ssh (Command Line), but all in vain. The only solution I found was to recompile the PHP with –with-webp-dir=DIR to enable WebP support. And it was not possible for me as I was using MongoDB and it requires to recompile PHP again and may cause some issues with database (Lemme clear! I am using two databases (MongoDB & MariaDB) and it may cause some conflicts). It took me several hours to find the perfect solution which works with any PHP above version 5.4 and does not require any installation. Moreover, this method is provided by Google, so no need to worry about site/server security. This method supports PHP only installed on any Linux distros like CentOS, Ubuntu, Debian or Fedora etc. So follow the steps below:
- Go to the official WebP library website.
- Download the package depending on your OS (Windows, Mac or Linux).
- Here we are talking about Linux, so download the latest package (For e.g. libwebp-1.1.0-rc2-linux-x86-64.tar.gz).
- The downloaded file format is tar.gz. You can use online converters like Cloudconvert to convert this format into zip format.
- Once converted and downloaded, extract the zip file and rename it to WebP folder.
- Upload the folder using FTP (home/domain) or Cpanel (public_html), depending on if you are using Nginx, Cpanel or whatever.
- Once uploaded, you are ready to convert your images to WebP format.
- To convert any image into WebP format use the PHP command below:
If still any issue, please write in the comment box below. Hope this tutorial is helpful in resolving your issue.
Источник
How can I Enable Webp support in php GD library in xampp on linux? #254
I have XAMPP for Linux 7.0.8.
And enabled with GD Support.
I want to use imagewebp(); .
I have error while using this,
Fatal error: Uncaught Error: Call to undefined function imagewebp()
while searching for a solution I have concluded with is solution from http://php.net/manual/en/image.installation.php
Image Format | Configure Switch
webp | To enable support for webp add —with-vpx-dir=DIR . Available as of PHP 5.5.
I want to enable webp support.
What I want to do?
The text was updated successfully, but these errors were encountered:
The PHP manual is not up-to-date (I’ll fix that ASAP). As of PHP 7.0.0 you have to use libwebp instead of libvpx and use the following for configure
What is the way to code —with-webp-dir=DIR with XAMPP installed linux machine?
I don’t know about XAMPP on Linux, but you may try first to simply leave out the DIR parameter, i.e.
If configure fails you’d have to look for the folder where libwebp is installed.
Maybe XAMPP already ships a compiled ext/gd with WebP support, in which case it might be sufficient to enable that in php.ini, see https://community.apachefriends.org/f/viewtopic.php?f=17&t=50328 for some hints.
And generally consider to ask on https://community.apachefriends.org/f/index.php; they’re suppossed to know their product better than anybody else. 🙂
Seems that it is a documentation issue, in PHP or xamp. Let close it.
Thanks for your response team.
I uninstalled XAMPP and reinstalled native LAMP stack server and I can recomplie my PHP.
For the record: the php.net documentation has been fixed.
Im new to PHP configuration and wanted to ask if its possible to enable Webp support on Centos 6.10 and if so how can it be done. Hope you can help me as I am really confused with this issue.
Im new to PHP configuration and wanted to ask if its possible to enable Webp support on Centos 6.10 and if so how can it be done. Hope you can help me as I am really confused with this issue.
GD has supported webp for a long time. I am not farmilar with php. But I think there must be a way to support Webp from the replys of @cmb69 in this issue. Did you check the document of php? Please specify the details of your problem so we can offer more help.
Hi,
Im new to PHP configuration and wanted to ask if its possible to enable Webp support on Centos 6.10 and if so how can it be done. Hope you can help me as I am really confused with this issue.
Regards,
GD has supported webp for a long time. I am not farmilar with php. But I think there must be a way to support Webp from the replys of @cmb69 in this issue. Did you check the document of php? Please specify the details of your problem so we can offer more help.
Right now the problem i have is that I want to enable Webp support on my gd library but are not sure hot to do it. I know my VPS uses Centos 6.10 but i dont know how to use commands to configure the gd library.
and i know that I am supposed to use the following command to enable it
—with-vpx-dir=DIR («DIR is the GD base install directory», but i am not sure how to determine the path in my server)
I don’t know were to use the command exactly. I have attached an image of my current gd configuration next to an example of what i am hopping to achieve. Hope you can help me get an idea on how to do it.
Источник
Add WebP support to GD (PHP Module)
BoxMan
Registered
In order to clarify the issue I don’t have any problem with install PHP with GD enabled but when I want to use imagewebp() I got an error:
After searching about the error I find the problem. I need to install GD —with-vpx-dir=DIR as I see in PHP.net: GD Installing/Configuring
I know EasyApache will search for additional GD feature libraries ( PHP Module: GD) :
- JPEG support > if find > libjpeg.so
- PNG support > if find > libpng.so
- XPM support > if find > libXpm.so
But what about WebP? is this something like this:
- WebP support > if find > libvpx.so
I installed libvpx & libvpx-devel and after that I find libvpx.so as same path as libXpm.so and other *.so than I rebuild EasyApache and I expected see —with-vpx-dir=DIR in my phpinfo()
configure command section, but nothing different and if I use imagewebp() got the error.
Where am I wrong? and how to enable imagewebp() on my server (CentOS 7 — 64bit).
cPanelMichael
Administrator
Could you let us know if the system uses EasyApache 3, or EasyApache 4? With EasyApache 3, you can use raw opts as documented at:
Information about an EasyApache 4 equivalent is discussed on the following thread:
BoxMan
Registered
Thanks for useful link.
I use EasyApache 3 and PHP 5. So I must create file:
with this content:
JacobPerkins
Well-Known Member
This *should* work, but attempt it and see how it works.
BoxMan
Registered
cPanelMichael
Administrator
—with-vpx-dir
—path-to-vpx-dir=/usr/lib64/libvpx.so
—my-option=
—with-webp-dir
—path-to-webp-dir=/usr/lib64/libwebp.so
—my-option=
Try using the following entries before running EasyApache again and let us know if it makes a difference:
BoxMan
Registered
it’s work, really thanks.
SunHunter
Member
Hi, I’m getting exactly the same issue as the original poster but using EasyApache 4 / PHP 7.4.
I’ve read the whole of this post, and would like to install GD using the ‘with-webp-dir’ option so that the imagewebp() function becomes available, but very stuck on how to do this with EasyApache4 (instructions above were for EA3).
I’ve noticed a file called gd.ini inside /opt/cpanel/ea-php74/root/etc/php.d/ but not sure if it’s just a case of appending the ‘with-webp-dir’ option to that file and then re-running EA? (a bit scared of doing this in case i bork the server)
(EDIT: I read on another thread that in EA 3 you could create a ‘rawopt’ file called ‘all_php_5’ for PHP configuration options, but an ‘all_php_7’ equivalent doesn’t seem to exist in EA 4 so not sure where’d you’d configure the installation of a specific extension?)
Источник
Внедряем поддержку формата изображений WebP
WebP – формат сжатия изображений, который в настоящее время примерно на 39% эффективнее jpeg.
Самый большой отрицательный бал в Google PageSpeed (инструмент проверки качества сайта) у вас скорее всего был связан с размером изображений. А все дело в том, что из коробки PHP ранее мог генерировать только простые jpeg, gif, png изображения без использования современных алгоритмов оптимизации.
Но начиная с PHP 7.1 мы смогли внедрить поддержку формата WebP в ReadyScript. Для всех, кто уже переключился на новую версию PHP (при условии, что PHP собран с поддержкой формата webp) теперь будет доступна опция «Генерировать для сайта миниатюры только в формате WebP» в настройках системного модуля. Включение данной опции будет означать, что отныне неважно в каком формате вы загрузили оригинал изображения (jpeg, gif, png), миниатюра будет сгенерирована в формате WebP.
Что с поддержкой браузерами?
- Google Chrome (начиная с 9 версии),
- Opera (начиная с версии 11.10)
- Firefox (с версии 65)
- Android поддерживает WebP изображений начиная с версии 4.0
Да, здесь нет, к сожалению, Safari то есть ни одно устройство Apple не поддерживает webp нативно. Традиционно здесь также нет IE, EDGE. Мы тоже сперва очень расстроились, но потом нашли решение. Существует отличный полифил, который эту поддержку добавляет.
Если опция генерации WebP будет включена, то мы автоматически подключаем специальный JS файл, который добавляет поддержку webp почти на всех браузерах.
Новая опция будет доступна всем пользователям ReadyScript бесплатно в рамках очередного обновления.
Обновление:
Просто версии PHP 7.1 недостаточно для работы формата изображений WebP. Если на вашем хостинге не генерируются изображения в формате webp, из-за ошибки «Fatal error: Uncaught Error: Call to undefined function imagewebp()», это означает, что PHP собран без флага поддержки формата webp, см. документацию: https://www.php.net/manual/ru/image.installation.php
Необходимо обратиться в поддержку вашего хостинга с вопросом о возможности сборки PHP с данной опцией.
Источник
Не поддерживаетя функция ImageCreateFromJpeg()
Google, Co.
Не поддерживаетя функция ImageCreateFromJpeg()
Не поддерживаетя функция:
Fatal error: Call to undefined function ImageCreateFromJpeg() in /var/www/User5/data/modules/catalog/admin/class.katalog.php on line 374
Идем далее:
C трудом, создавая пути /usr/local/jpeg-6b/bin & /usr/local/jpeg-6b/man компилирую
make
make install
Далее скачиваю и конфигурирую gd
вот такой вот неутешающий результат:
Support for PNG library: no
Support for JPEG library: no
Support for Freetype 2.x library: no
Support for Fontconfig library: no
Support for Xpm library: no
Support for pthreads: yes
не поддерживает jpeg, что делать?
shtogrin
Google, Co.
‘./configure’ ‘—with-apxs=/usr/local/apache/bin/apxs’ ‘—with-libxml-dir=/usr/local/libxml’ ‘—with-xsl=/usr/local/libxslt’ ‘—with-iconv=/usr/local/iconv’ ‘—enable-track-vars’ ‘—enable-mod_charset’ ‘—with-dom’ ‘—with-dom-xslt’ ‘—with-dom-exslt’ ‘—with-mysql=/usr/local/mysql’ ‘—prefix=/usr/local/php5’ ‘—with-jpeg-dir=/usr/local’
ошибка как была так и осталась
Fatal error: Call to undefined function ImageCreateFromJpeg() in /var/www/User5/data/modules/catalog/admin/class.katalog.php on line 374
Что посоветуете?
Спасибо
shtogrin
make clean
configure . —with-gd
make
в config.log найти jpeg и посмотреть что не нравиться
Google, Co.
при configure не может найти libjpeg, хотя как писал выше скачал ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz и просто установил в /usr/local/
./prefix=/usr/local
make
make install
все нормально прошло
потом
./configure —with-apxs=/usr/local/apache/bin/apxs —with-libxml-dir=/usr/local/libxml —with-xsl=/usr/local/libxslt —with-iconv=/usr/local/iconv —enable-track-vars —enable-mod_charset —with-dom —with-dom-xslt —with-dom-exslt —with-mysql=/usr/local/mysql —prefix=/usr/local/php5 —with-jpeg-dir=/usr/local/bin —with-gd
configure: error: libjpeg.(a|so) not found.
shtogrin
tony2001
TeaM PHPClub
Google, Co.
А нет libjpeg.so, вот что есть:
/usr/bin/install -c cjpeg /usr/local/jpeg-6b/bin/cjpeg
/usr/bin/install -c djpeg /usr/local/jpeg-6b/bin/djpeg
/usr/bin/install -c jpegtran /usr/local/jpeg-6b/bin/jpegtran
/usr/bin/install -c rdjpgcom /usr/local/jpeg-6b/bin/rdjpgcom
/usr/bin/install -c wrjpgcom /usr/local/jpeg-6b/bin/wrjpgcom
/usr/bin/install -c -m 644 ./cjpeg.1 /usr/local/jpeg-6b/man/man1/cjpeg.1
/usr/bin/install -c -m 644 ./djpeg.1 /usr/local/jpeg-6b/man/man1/djpeg.1
/usr/bin/install -c -m 644 ./jpegtran.1 /usr/local/jpeg-6b/man/man1/jpegtran.1
/usr/bin/install -c -m 644 ./rdjpgcom.1 /usr/local/jpeg-6b/man/man1/rdjpgcom.1
/usr/bin/install -c -m 644 ./wrjpgcom.1 /usr/local/jpeg-6b/man/man1/wrjpgcom.1
tony2001
TeaM PHPClub
shtogrin
Google, Co.
Скомпилировал jpeg-6b, получил libjpeg.a
Указываю:
hosting# ./configure —with-apxs=/usr/local/apache/bin/apxs —with-libxml-dir=/usr/local/libxml —with-xsl=/usr/local/libxslt —with-iconv=/usr/local/iconv —enable-track-vars —enable-mod_charset —with-dom —with-dom-xslt —with-dom-exslt —with-mysql=/usr/local/mysql —prefix=/usr/local/php5 —with-gd —with-jpeg-dir=/usr/local/jpeg-6b/lib
и все равно не видит
configure: error: libjpeg.(a|so) not found.
Источник
-
oc 3.0.3.2, хостинг — VestaCP,
после установки нового шаблона не работает модификатор преобразования webp, если его отключить то ошибка уходит но на сайте все коряво,
РЕБЯТА, помогите настроить nginx.conf на отдачу webp,
У меня пишет такую ошибку на самом сайте :
Fatal error: Uncaught Error: Call to undefined function imagewebp() in /home/admin/web/mebelomskabsolut.ru/public_html/system/storage/modification/catalog/model/tool/image.php:64 Stack trace: #0 /home/admin/web/mebelomskabsolut.ru/public_html/system/storage/modification/system/engine/loader.php(248): ModelToolImage->resize(‘no_image.png’, 100, 100) #1 /home/admin/web/mebelomskabsolut.ru/public_html/system/engine/proxy.php(47): Loader->{closure}(Array, Array) #2 /home/admin/web/mebelomskabsolut.ru/public_html/catalog/controller/extension/module/so_home_slider.php(93): Proxy->__call(‘resize’, Array) #3 /home/admin/web/mebelomskabsolut.ru/public_html/catalog/controller/extension/module/so_home_slider.php(36): ControllerExtensionModuleSohomeslider->readData(Array) #4 /home/admin/web/mebelomskabsolut.ru/public_html/system/storage/modification/system/engine/action.php(79): ControllerExtensionModuleSohomeslider->index(Array) #5 /home/admin/web/mebelomskabsolut.ru/public_html/system/storage/modification/system/engine/loader.php(4 in /home/admin/web/mebelomskabsolut.ru/public_html/system/storage/modification/catalog/model/tool/image.php on line 64вот содержимое модификатора в админке:
<?xml version=»1.0″ encoding=»utf-8″?>
<modification>
<name>So convert image WebP</name>
<code>so-convert-image-WebP</code>
<version>1.0.0</version>
<author>OpenCartWorks</author>
<link>http://www.opencartworks.com/</link><file path=»catalog/model/tool/image.php»>
<operation>
<search trim=»true»>
<![CDATA[if ($this->request->server[‘HTTPS’]) {]]>
</search>
<add position=»before» trim=»false»>
<![CDATA[
$this->load->model(‘extension/soconfig/general’);
if($this->soconfig->get_settings(‘enable_convert_image_webP’) === ‘1’) {
if($extension == ‘jpg’ || $extension == ‘png’ || $extension == ‘gif’ || $extension == ‘jpeg’) {
// Image
$dir = DIR_IMAGE;
$name = $image_new;
$newName = utf8_substr($image_new, 0, utf8_strrpos($image_new, ‘.’)) . ‘.webp’;
// Create and save
if (!is_file(DIR_IMAGE . $newName)) {
if ($extension == ‘jpeg’ && $this->soconfig->get_settings(‘jpg_convert_image_webP’) === ‘1’ || $extension == ‘jpg’ && $this->soconfig->get_settings(‘jpg_convert_image_webP’) === ‘1’)
$img = imagecreatefromjpeg($dir.$name);
elseif ($extension == ‘gif’ && $this->soconfig->get_settings(‘gif_convert_image_webP’) === ‘1’)
$img = imagecreatefromgif($dir.$name);
elseif ($extension == ‘png’ && $this->soconfig->get_settings(‘png_convert_image_webP’) === ‘1’)
$img = imagecreatefrompng($dir.$name);imagepalettetotruecolor($img);
imagealphablending($img, true);
imagesavealpha($img, true);imagewebp($img, $dir . $newName, 100);
imagedestroy($img);
} else {
if ($extension == ‘jpeg’ && $this->soconfig->get_settings(‘jpg_convert_image_webP’) === ‘1’ || $extension == ‘jpg’ && $this->soconfig->get_settings(‘jpg_convert_image_webP’) === ‘1’)
$image_new = $newName;
elseif ($extension == ‘gif’ && $this->soconfig->get_settings(‘gif_convert_image_webP’) === ‘1’)
$image_new = $newName;
elseif ($extension == ‘png’ && $this->soconfig->get_settings(‘png_convert_image_webP’) === ‘1’)
$image_new = $newName;}
}
}
]]>
</add>
</operation>
</file>
</modification> -
zema50
Продвинутый пользователь- Сообщения:
- 708
- Симпатии:
- 80
вы наверно покупали модуль на варезнике ?
у вас в ошибке Call to undefined function imagewebp() ясно написано нет функции imagewebp()
тут nginx не при чем. -
Здравствуйте
Функция является внутренней для php — https://www.php.net/manual/ru/function.imagewebp.php
Смотрите версию окружения сайта (к примеру, какая версия php) + какие у вас настройки.
Добавлено: Если у вас варезный софт, то проще купите модуль у автора и попросите решить проблему (а может и сама решится)
-
Blast
Активный пользователь- Сообщения:
- 140
- Симпатии:
- 48
обратитесь к хостеру, похоже нужно сконфигурировать php с правильными параметрами
https://stackoverflow.com/questions/57651877/call-to-undefined-function-imagewebp
Today, I came across a problem when I have shifted my websites to a new server having PHP 7 installed. One of my websites uses PHP imagewebp() function to generate WebP images. I was using centos 7.x server with Nginx installed and PHP version was 7.0. When I was trying to generate WebP images, I was getting error fatal error: Uncaught Error: Call to undefined function imagewebp(). I searched google and tried various tutorials in order to solve this issue, but all in vain. After trying several hours, I found the alternate solution to generate WebP images without recompiling PHP and without installing any package. Also, this method doesn’t require root access to the server. So, read this tutorial to know, how to enable WebP support in GD library for PHP 7 in CentOS Nginx.
What is WebP & Why its Important?
WebP format of the image was developed by Google. The reason behind it was to make small size images with lossless compression in order to make web pages smaller and serve them fast. WebP format is the successor to jpeg format.
According to Google: WebP is a modern image format which provides superior lossless and lossy compression for images. Using WebP, web developers can create smaller, richer images that make the web faster.
Now it’s clear that Google is forcing web developers to serve WebP images in order to make web pages much faster. WebP images are 26% smaller in size compared to png, 25-34% smaller than jpeg images. In short, WebP images are approximately 3 times smaller than other formats.
Does All Browser Support WebP Format Images?
No, all browser do not support WebP format images. WebP was created google and it is supported by google official Chrome web browser and other browsers like Microsoft Edge, Firefox & Opera. However, it is not supported by some of the major browsers like Safari.
But there’s a method to serve images according to browser compatibility. For this, we need to write a bit of HTML code. Here’s the HTML code below:
<picture>
<source srcset="https://domain.com/image.webp" type="image/webp">
<img src="https://domain.com/image.jpg" alt="Demo Image" />
</picture>
Using the above code, we can serve the supported image format to browser depending on the compatibility of WebP format.
How to enable WebP support in PHP 7.x or Any Version?
As I wrote above, I tried to enable WebP support using ssh (Command Line), but all in vain. The only solution I found was to recompile the PHP with –with-webp-dir=DIR to enable WebP support. And it was not possible for me as I was using MongoDB and it requires to recompile PHP again and may cause some issues with database (Lemme clear! I am using two databases (MongoDB & MariaDB) and it may cause some conflicts). It took me several hours to find the perfect solution which works with any PHP above version 5.4 and does not require any installation. Moreover, this method is provided by Google, so no need to worry about site/server security. This method supports PHP only installed on any Linux distros like CentOS, Ubuntu, Debian or Fedora etc. So follow the steps below:
- Go to the official WebP library website.
- Download the package depending on your OS (Windows, Mac or Linux).
- Here we are talking about Linux, so download the latest package (For e.g. libwebp-1.1.0-rc2-linux-x86-64.tar.gz).
- The downloaded file format is tar.gz. You can use online converters like Cloudconvert to convert this format into zip format.
- Once converted and downloaded, extract the zip file and rename it to WebP folder.
- Upload the folder using FTP (home/domain) or Cpanel (public_html), depending on if you are using Nginx, Cpanel or whatever.
- Once uploaded, you are ready to convert your images to WebP format.
- To convert any image into WebP format use the PHP command below:
<?php
echo shell_exec("webp/bin/cwebp -q 60 demo.jpg -o img/demo.webp");
?>
If still any issue, please write in the comment box below. Hope this tutorial is helpful in resolving your issue.
-
#1
In order to clarify the issue I don’t have any problem with install PHP with GD enabled but when I want to use imagewebp() I got an error:
Code:
Fatal error: Call to undefined function imagewebp()
After searching about the error I find the problem. I need to install GD —with-vpx-dir=DIR as I see in PHP.net: GD Installing/Configuring
I know EasyApache will search for additional GD feature libraries (PHP Module: GD):
- JPEG support > if find > libjpeg.so
- PNG support > if find > libpng.so
- XPM support > if find > libXpm.so
But what about WebP? is this something like this:
- WebP support > if find > libvpx.so
I installed libvpx & libvpx-devel and after that I find libvpx.so as same path as libXpm.so and other *.so than I rebuild EasyApache and I expected see —with-vpx-dir=DIR in my phpinfo()
configure command section, but nothing different and if I use imagewebp() got the error.
Where am I wrong? and how to enable imagewebp() on my server (CentOS 7 — 64bit).
-
#3
Thanks for useful link.
I use EasyApache 3 and PHP 5. So I must create file:
Code:
/var/cpanel/easy/apache/rawopts/all_php5
with this content:
Code:
--with-vpx-dir
--path-to-vpx-dir=/usr/lib64/libvpx.so
--my-option=
--with-webp-dir
--path-to-webp-dir=/usr/lib64/libwebp.so
--my-option=
And than rebuild, is it true?
-
#4
Hi BoxMan,
This *should* work, but attempt it and see how it works.
-
#5
thanks, but no change. it’s not work for me. I do as I said in last post.
-
#6
—with-vpx-dir
—path-to-vpx-dir=/usr/lib64/libvpx.so
—my-option=—with-webp-dir
—path-to-webp-dir=/usr/lib64/libwebp.so
—my-option=
Hello,
Try using the following entries before running EasyApache again and let us know if it makes a difference:
Code:
--with-vpx-dir=/usr
--with-webp-dir=/usr
Thank you.
-
#7
hooray !!
it’s work, really thanks.
Codes in box..
-
#8
Hi, I’m getting exactly the same issue as the original poster but using EasyApache 4 / PHP 7.4.
I’ve read the whole of this post, and would like to install GD using the ‘with-webp-dir’ option so that the imagewebp() function becomes available, but very stuck on how to do this with EasyApache4 (instructions above were for EA3).
I’ve noticed a file called gd.ini inside /opt/cpanel/ea-php74/root/etc/php.d/ but not sure if it’s just a case of appending the ‘with-webp-dir’ option to that file and then re-running EA? (a bit scared of doing this in case i bork the server)
(EDIT: I read on another thread that in EA 3 you could create a ‘rawopt’ file called ‘all_php_5’ for PHP configuration options, but an ‘all_php_7’ equivalent doesn’t seem to exist in EA 4 so not sure where’d you’d configure the installation of a specific extension?)
Last edited: May 18, 2020
-
#9
Now rolled my own imagewebp() function as I had a live site that needed the functionality (upgraded a site from an older version of PHP that already had the same function). For anyone else, I installed Google’s cwebp library and I’m calling it from PHP (works well enough).
PHP:
exec('cwebp -q ' . $quality . ' ' . $jpegFileName . ' -o ' . $webpFileName);
(Don’t really like relying too much on external libraries, but there doesn’t seem much other option here)
WebP – формат сжатия изображений, который в настоящее время примерно на 39% эффективнее jpeg.
Самый большой отрицательный бал в Google PageSpeed (инструмент проверки качества сайта) у вас скорее всего был связан с размером изображений. А все дело в том, что из коробки PHP ранее мог генерировать только простые jpeg, gif, png изображения без использования современных алгоритмов оптимизации.
Но начиная с PHP 7.1 мы смогли внедрить поддержку формата WebP в ReadyScript. Для всех, кто уже переключился на новую версию PHP (при условии, что PHP собран с поддержкой формата webp) теперь будет доступна опция «Генерировать для сайта миниатюры только в формате WebP» в настройках системного модуля. Включение данной опции будет означать, что отныне неважно в каком формате вы загрузили оригинал изображения (jpeg, gif, png), миниатюра будет сгенерирована в формате WebP.
Что с поддержкой браузерами?
Поддержка следующая:
- Google Chrome (начиная с 9 версии),
- Opera (начиная с версии 11.10)
- Firefox (с версии 65)
- Android поддерживает WebP изображений начиная с версии 4.0
Да, здесь нет, к сожалению, Safari то есть ни одно устройство Apple не поддерживает webp нативно. Традиционно здесь также нет IE, EDGE. Мы тоже сперва очень расстроились, но потом нашли решение. Существует отличный полифил, который эту поддержку добавляет.
Если опция генерации WebP будет включена, то мы автоматически подключаем специальный JS файл, который добавляет поддержку webp почти на всех браузерах.
Новая опция будет доступна всем пользователям ReadyScript бесплатно в рамках очередного обновления.
Обновление:
Просто версии PHP 7.1 недостаточно для работы формата изображений WebP. Если на вашем хостинге не генерируются изображения в формате webp, из-за ошибки «Fatal error: Uncaught Error: Call to undefined function imagewebp()», это означает, что PHP собран без флага поддержки формата webp, см. документацию: https://www.php.net/manual/ru/image.installation.php
Необходимо обратиться в поддержку вашего хостинга с вопросом о возможности сборки PHP с данной опцией.
04 апреля 2019 16:55, Артем Полторанин