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

**URL:** <https://travis-ci.community/t/how-to-enable-webp-image-format-support-in-php-7/3209>\
**Category:** PHP\
**Created:** [April 28, 2019, 4:17pm UTC](https://travis-ci.community/t/how-to-enable-webp-image-format-support-in-php-7/3209 "2019-04-28T16:17:10Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![peter279k](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/peter279k/32/1707_2.png) [@peter279k](https://travis-ci.community/u/peter279k)\
**Post date:** [April 28, 2019, 4:17pm UTC](https://travis-ci.community/t/how-to-enable-webp-image-format-support-in-php-7/3209/1 "2019-04-28T16:17:10Z")

</div>

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

```auto
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](https://travis-ci.org/peter279k/php-image-converter/jobs/525593113).

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

Here is my `Dockerfile`:

```auto
# 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 🙂.

---

<div class="post-metadata">

**Author:** ![jarednova](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/jarednova/32/1960_2.png) [@jarednova](https://travis-ci.community/u/jarednova)\
**Post date:** [January 3, 2020, 4:30pm UTC](https://travis-ci.community/t/how-to-enable-webp-image-format-support-in-php-7/3209/2 "2020-01-03T16:30:08Z")

</div>

@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?

---

<div class="post-metadata">

**Author:** ![peter279k](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/peter279k/32/1707_2.png) [@peter279k](https://travis-ci.community/u/peter279k)\
**Post date:** [January 3, 2020, 5:04pm UTC](https://travis-ci.community/t/how-to-enable-webp-image-format-support-in-php-7/3209/3 "2020-01-03T17:04:03Z")

</div>

Hi @jarednova, thanks for your reply and concern 🙂 .

Unfortunately, this issue still happens on my Travis CI build and you can look at this [repository](https://github.com/peter279k/php-travis-webp).

It’s for testing this issue. As you can look at the [Travis CI build log](https://travis-ci.org/peter279k/php-travis-webp/jobs/632366676), the gd extension is loaded on PHP run time, but the `imagewebp` function is not existed.

---

<div class="post-metadata">

**Author:** ![peter279k](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/peter279k/32/1707_2.png) [@peter279k](https://travis-ci.community/u/peter279k)\
**Post date:** [January 3, 2020, 5:20pm UTC](https://travis-ci.community/t/how-to-enable-webp-image-format-support-in-php-7/3209/4 "2020-01-03T17:20:20Z")

</div>

@jarednova. If you want to fix this issue temporarily, you can look at another [repository](https://github.com/peter279k/php-travis-gd) I create.

As you can look at [Travis CI build log](https://travis-ci.org/peter279k/php-travis-gd/jobs/632371476), this Travis CI build doesn’t use pre-built PHP versions and enable `sudo` to install remote PHP versions.

---

<div class="post-metadata">

**Author:** ![jarednova](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/jarednova/32/1960_2.png) [@jarednova](https://travis-ci.community/u/jarednova)\
**Post date:** [January 3, 2020, 7:46pm UTC](https://travis-ci.community/t/how-to-enable-webp-image-format-support-in-php-7/3209/5 "2020-01-03T19:46:47Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![manerkargaurav](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/manerkargaurav/32/5528_2.png) [@manerkargaurav](https://travis-ci.community/u/manerkargaurav)\
**Post date:** [November 9, 2020, 5:46am UTC](https://travis-ci.community/t/how-to-enable-webp-image-format-support-in-php-7/3209/6 "2020-11-09T05:46:27Z")

</div>

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

 ![Screenshot 2020-11-09 at 11.15.52 AM](https://us1.discourse-cdn.com/flex015/uploads/travis_ci/original/2X/0/02f0ffe8f73d7d23e1031801f5e1fe79290323a0.png)

---

<div class="post-metadata">

**Author:** ![peter279k](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/peter279k/32/1707_2.png) [@peter279k](https://travis-ci.community/u/peter279k)\
**Post date:** [November 9, 2020, 7:05am UTC](https://travis-ci.community/t/how-to-enable-webp-image-format-support-in-php-7/3209/7 "2020-11-09T07:05:09Z")

</div>

Hi @manerkargaurav. Thanks for your reply.

Which solutions do you use?

Do you refer this [one](https://github.com/peter279k/php-travis-gd)?

---

<div class="post-metadata">

**Author:** ![peter279k](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/peter279k/32/1707_2.png) [@peter279k](https://travis-ci.community/u/peter279k)\
**Post date:** [November 9, 2020, 7:18am UTC](https://travis-ci.community/t/how-to-enable-webp-image-format-support-in-php-7/3209/8 "2020-11-09T07:18:01Z")

</div>

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](https://travis-ci.org/github/peter279k/php-travis-gd).

---

<div class="post-metadata">

**Author:** ![manerkargaurav](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/manerkargaurav/32/5528_2.png) [@manerkargaurav](https://travis-ci.community/u/manerkargaurav)\
**Post date:** [November 9, 2020, 7:19am UTC](https://travis-ci.community/t/how-to-enable-webp-image-format-support-in-php-7/3209/9 "2020-11-09T07:19:01Z")

</div>

Hi @peter279k  
Yes

> <https://github.com/peter279k/php-travis-gd/blob/master/.travis.yml>

---

<div class="post-metadata">

**Author:** ![peter279k](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/peter279k/32/1707_2.png) [@peter279k](https://travis-ci.community/u/peter279k)\
**Post date:** [November 9, 2020, 7:20am UTC](https://travis-ci.community/t/how-to-enable-webp-image-format-support-in-php-7/3209/10 "2020-11-09T07:20:30Z")

</div>

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

And it seems that you run `php` command.

---

<div class="post-metadata">

**Author:** ![manerkargaurav](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/manerkargaurav/32/5528_2.png) [@manerkargaurav](https://travis-ci.community/u/manerkargaurav)\
**Post date:** [November 9, 2020, 7:22am UTC](https://travis-ci.community/t/how-to-enable-webp-image-format-support-in-php-7/3209/11 "2020-11-09T07:22:31Z")

</div>

Hi @peter279k  
Can you print gd\_info() at your end and check if webp\_supported is set to true ?

---

<div class="post-metadata">

**Author:** ![peter279k](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/peter279k/32/1707_2.png) [@peter279k](https://travis-ci.community/u/peter279k)\
**Post date:** [November 9, 2020, 7:25am UTC](https://travis-ci.community/t/how-to-enable-webp-image-format-support-in-php-7/3209/12 "2020-11-09T07:25:51Z")

</div>

Sure. You can look at this recent [Travis CI build log](https://travis-ci.org/github/peter279k/php-travis-gd/jobs/742374858).

And these captured pictures are as follows:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/travis_ci/original/2X/1/18c1e30101910c00aa69fbc23c66fcfed0905e19.png)

 ![image](https://us1.discourse-cdn.com/flex015/uploads/travis_ci/original/2X/0/0edfb15afdf122d118fa0cd18c41690156ebdac7.png)

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

---

<div class="post-metadata">

**Author:** ![manerkargaurav](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/manerkargaurav/32/5528_2.png) [@manerkargaurav](https://travis-ci.community/u/manerkargaurav)\
**Post date:** [November 9, 2020, 7:30am UTC](https://travis-ci.community/t/how-to-enable-webp-image-format-support-in-php-7/3209/13 "2020-11-09T07:30:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![peter279k](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/peter279k/32/1707_2.png) [@peter279k](https://travis-ci.community/u/peter279k)\
**Post date:** [November 9, 2020, 8:10am UTC](https://travis-ci.community/t/how-to-enable-webp-image-format-support-in-php-7/3209/14 "2020-11-09T08:10:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![manerkargaurav](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/manerkargaurav/32/5528_2.png) [@manerkargaurav](https://travis-ci.community/u/manerkargaurav)\
**Post date:** [November 9, 2020, 8:23am UTC](https://travis-ci.community/t/how-to-enable-webp-image-format-support-in-php-7/3209/15 "2020-11-09T08:23:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![peter279k](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/peter279k/32/1707_2.png) [@peter279k](https://travis-ci.community/u/peter279k)\
**Post date:** [November 9, 2020, 8:37am UTC](https://travis-ci.community/t/how-to-enable-webp-image-format-support-in-php-7/3209/16 "2020-11-09T08:37:56Z")

</div>

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 🙂.

---

<div class="post-metadata">

**Author:** ![manerkargaurav](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/manerkargaurav/32/5528_2.png) [@manerkargaurav](https://travis-ci.community/u/manerkargaurav)\
**Post date:** [November 9, 2020, 8:39am UTC](https://travis-ci.community/t/how-to-enable-webp-image-format-support-in-php-7/3209/17 "2020-11-09T08:39:32Z")

</div>

ok thanks

---

<div class="post-metadata">

**Author:** ![peter279k](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/peter279k/32/1707_2.png) [@peter279k](https://travis-ci.community/u/peter279k)\
**Post date:** [November 9, 2020, 10:59am UTC](https://travis-ci.community/t/how-to-enable-webp-image-format-support-in-php-7/3209/18 "2020-11-09T10:59:02Z")

</div>

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](https://github.com/peter279k/php-travis-gd/blob/master/.travis.yml) file 🙂 .

---

<div class="post-metadata">

**Author:** ![manerkargaurav](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/manerkargaurav/32/5528_2.png) [@manerkargaurav](https://travis-ci.community/u/manerkargaurav)\
**Post date:** [November 10, 2020, 7:13am UTC](https://travis-ci.community/t/how-to-enable-webp-image-format-support-in-php-7/3209/19 "2020-11-10T07:13:04Z")

</div>

Can you try restarting php ?

---

<div class="post-metadata">

**Author:** ![peter279k](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/peter279k/32/1707_2.png) [@peter279k](https://travis-ci.community/u/peter279k)\
**Post date:** [November 10, 2020, 7:26am UTC](https://travis-ci.community/t/how-to-enable-webp-image-format-support-in-php-7/3209/20 "2020-11-10T07:26:07Z")

</div>

You can look at latest [Travis CI build log](https://travis-ci.org/github/peter279k/php-travis-gd).

[Next page](https://travis-ci.community/t/how-to-enable-webp-image-format-support-in-php-7/3209.md?page=2)
