Docker Community Forums

Share and learn in the Docker community.

Call to undefined function imagewebp (Dockerfile, php, gd, webp)

I’m not able to enable webp support inside a docker container.

When execute php script I get this error:

Fatal error: Uncaught Error: Call to undefined function imagewebp()....

Executing php -i to see if gd is enabled:

root@a5e8fec22e8b:/var/www/html# php -i | grep -ia gd  
Additional .ini files parsed => /usr/local/etc/php/conf.d/docker-php-ext-gd.ini,
gd
GD Support => enabled                                    <--------- GD is enabled
GD Version => bundled (2.1.0 compatible)
gd.jpeg_ignore_warning => 1 => 1

php gd_info output:

"GD Version":"bundled (2.1.0 compatible)",
"FreeType Support":true,
"FreeType Linkage":"with freetype",
"GIF Read Support":true,
"GIF Create Support":true,
"JPEG Support":true,
"PNG Support":true,"WBMP Support":true,
"XPM Support":false,
"XBM Support":true,
"WebP Support":false,    <----------------------------- :?
"BMP Support":true,
"JIS-mapped Japanese Font Support":false

Dockerfile

FROM php:7.2-apache

COPY ./apache2/sites-available/*.conf /etc/apache2/sites-available/

RUN apt-get update && apt-get install --no-install-recommends -y \
    wget \
    nano \
    git \
    unzip \
    iputils-ping

# Install PHP extensions deps
RUN apt-get update \
    && apt-get install --no-install-recommends -y \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libjpeg-dev \
        libwebp-dev \
        libpng-dev \
        libmcrypt-dev \
        zlib1g-dev \
        libicu-dev \
        g++ \
        unixodbc-dev \
        libxml2-dev \
        libaio-dev \
        libmemcached-dev \
        freetds-dev \
        libssl-dev \
        openssl \
        libsodium-dev
        

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- \
        --install-dir=/usr/local/bin \
        --filename=composer

# Install PHP extensions
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-webp-dir=/usr/include/ \
    && docker-php-ext-configure pdo_dblib --with-libdir=/lib/x86_64-linux-gnu \
    && pecl install sqlsrv-4.1.6.1 \
    && pecl install pdo_sqlsrv-4.1.6.1 \
    && pecl install redis \
    && pecl install memcached \
    && pecl install -f libsodium \
    && docker-php-ext-install \
            iconv \
            mbstring \
            intl \
            gd \
            mysqli \
            pdo_mysql \
            pdo_dblib \
            soap \
            sockets \
            sodium \
            zip \
            pcntl \
            ftp \
    && docker-php-ext-enable \
            sqlsrv \
            pdo_sqlsrv \
            redis \
            memcached \
            opcache \
            gd \
            sodium

RUN a2enmod rewrite negotiation

RUN mkdir /home/laravel && \        
         chown -R www-data:www-data /home/laravel

RUN chown -R www-data:www-data /var/www

RUN service apache2 restart