montintin
montintin

Reputation: 11

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

Upvotes: 0

Views: 2788

Answers (2)

montintin
montintin

Reputation: 11

Yes I had to compile gd

First I removed the old version sudo yum remove php-gd

then check php version php -v

get the src sudo 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 these sudo 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 enable sudo nano /etc/php.ini

add extension=gd

then it is available php -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) }

Upvotes: 1

Giorgos Yiakoumettis
Giorgos Yiakoumettis

Reputation: 97

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.

https://www.cloudinary.com/

https://cloudconvert.com/

https://uploadcare.com/

https://www.imghaste.com/

or even convert them offline: https://www.imghaste.com/converter

Upvotes: 0

Related Questions