php - How can I add WebP support to a php7.2 install in a amazon linux 2 box?

In a new amazon linux2 box I ran the following:
sudo amazon-linux-extras install php7.2
sudo yum install php-gd
But then when I run:
php -r 'var_dump(gd_info());'
I get:
array(13) {
["GD Version"]=>
string(26) "bundled (2.1.0 compatible)"
["FreeType Support"]=>
bool(true)
["FreeType Linkage"]=>
string(13) "with freetype"
["GIF Read Support"]=>
bool(true)
["GIF Create Support"]=>
bool(true)
["JPEG Support"]=>
bool(true)
["PNG Support"]=>
bool(true)
["WBMP Support"]=>
bool(true)
["XPM Support"]=>
bool(true)
["XBM Support"]=>
bool(true)
["WebP Support"]=>
bool(false)
["BMP Support"]=>
bool(true)
["JIS-mapped Japanese Font Support"]=>
bool(false)
}
I don't know what I have to do to have WebP Support as true
Answer
Solution:
Yes I had to compile gd
First I removed the old versionsudo yum remove php-gd
then check php versionphp -v
get the srcsudo wget https://github.com/php/php-src/archive/php-7.2.3.tar.gz
sudo tar zxf php-7.2.3.tar.gz
cd php-src-php-7.2.3/ext/gd/
I had to install thesesudo yum install php-devel gd-devel libwebp-devel libjpeg-turbo-devel
sudo yum groupinstall "Development Tools"
sudo yum install libwebp-devel libjpeg-devel libpng-devel zlib-devel libXpm-devel
sudo phpize
sudo ./configure --with-jpeg-dir --with-freetype-dir --with-xpm-dir --with-webp-dir --with-png-dir --with-zlib-dir
sudo make
sudo cp modules/gd.so /usr/lib64/php/modules/
and then edit php.ini to enablesudo nano /etc/php.ini
addextension=gd
then it is availablephp -m
php -r 'var_dump(gd_info());'
array(13) {
["GD Version"]=>
string(26) "bundled (2.1.0 compatible)"
["FreeType Support"]=>
bool(true)
["FreeType Linkage"]=>
string(13) "with freetype"
["GIF Read Support"]=>
bool(true)
["GIF Create Support"]=>
bool(true)
["JPEG Support"]=>
bool(true)
["PNG Support"]=>
bool(true)
["WBMP Support"]=>
bool(true)
["XPM Support"]=>
bool(true)
["XBM Support"]=>
bool(true)
["WebP Support"]=>
bool(true)
["BMP Support"]=>
bool(true)
["JIS-mapped Japanese Font Support"]=>
bool(false)
}
Answer
Solution:
You probably need to compile gd.so from source with WebP Support.
GD was already there, WebP Support was/is missing.
Possible Duplicate: How to compile php to enable webp support?
You also may use a free image service to do this work for you.
or even convert them offline: https://www.imghaste.com/converter
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: call to a member function store() on null
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.