How to enable WEBP image format support in PHP 7.*?

As title, I’ve used the following .travis.yml setting to build my CI environment.

language: php

php:
  - 7.1
  - 7.2
  - 7.3

before_script:
  - composer install

script:
  - mkdir -p build/logs
  - ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml

after_success:
  - travis_retry php vendor/bin/php-coveralls -v

But it’s undefined when using the imagewep function on every PHP version.

The detailed build log is available here.

And I use the Docker to build a container and it’s worked fine for the imagewebp function.

Here is my Dockerfile:

# Install required packages
FROM ubuntu:14.04
RUN apt-get update
RUN apt-get install -y software-properties-common
RUN apt-get install -y python-software-properties
RUN LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
RUN apt-get update
RUN apt-get install -y apt-transport-https apt-utils curl php7.1-gd php7.1-cli

CMD ["bash", "-c", "php -r 'echo function_exists(\"imagewebp\");'"]

I think the default PHP versions in Travis CI build may have the webp image issues for GD extension.

Please help me to check/concern that :slight_smile:.

@peter279k I’m running into the same issue trying to test against WEBP/GD stuff that’s being skipped right now. Did you ever have any luck getting tests going?

1 Like

Hi @jarednova, thanks for your reply and concern :slight_smile: .

Unfortunately, this issue still happens on my Travis CI build and you can look at this repository.

It’s for testing this issue. As you can look at the Travis CI build log, the gd extension is loaded on PHP run time, but the imagewebp function is not existed.

@jarednova. If you want to fix this issue temporarily, you can look at another repository I create.

As you can look at Travis CI build log, this Travis CI build doesn’t use pre-built PHP versions and enable sudo to install remote PHP versions.

1 Like

Awesome, thanks @peter279k!!! I’ll take a look at those and see if I can pull that stuff into mine. Thanks for the quick response!

1 Like

Hello @peter279k,
Your solution doesn’t wok for me.
Webp_support showing as false in build log.

Hi @manerkargaurav. Thanks for your reply.

Which solutions do you use?

Do you refer this one?

Just notice that it should use sudo php to call PHP file or others because it will support webp on GD extension after installing PHP manually on Travis CI build.

More details are available on Travis CI build log.

Hi @peter279k
Yes

Do you use the sudo php to run your PHP processes?

And it seems that you run php command.

Hi @peter279k
Can you print gd_info() at your end and check if webp_supported is set to true ?

Sure. You can look at this recent Travis CI build log.

And these captured pictures are as follows:

You can see different results about sudo php and php commands :).

Hi @peter279k
Can you pls provide me link to view updated .travis.yml file ?

Here it is: https://github.com/peter279k/php-travis-gd/blob/master/.travis.yml

Thanks @peter279k
But i need solution without sudo command. As webp library is used in module.
Any alterate solution you have ?

Recently I try to figure out the solution about using PHP with GD and WebP supports without sudo prefix.

But I don’t have the current way to fix above issue.

If I have the current solution, I will let you know :slight_smile:.

1 Like

ok thanks

After using which php and sudo which php to find current PHP executing path, I change sudo php to /usr/bin/php.

You can look at more details about .travis.yml file :slight_smile: .

Can you try restarting php ?

You can look at latest Travis CI build log.