docker-library / php

Docker Official Image packaging for PHP

Home Page:https://php.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gd has unrecognized options in PHP 7.4

patrickomeara opened this issue · comments

During an upgrade to PHP 7.4 I can't specify options to docker-php-ext-configure

test Dockerfile below

FROM php:7.4.0-apache

# packages
RUN apt-get update \
  && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
  # needed for gd
  libfreetype6-dev \
  libjpeg62-turbo-dev \
  libpng-dev \
  && rm -rf /var/lib/apt/lists/*

# GD
RUN docker-php-ext-configure gd --with-freetype-dir=/usr --with-jpeg-dir=/usr --with-png-dir=/usr \
  && docker-php-ext-install -j "$(nproc)" gd

RUN php -r 'var_dump(gd_info());'

output from step 3

configure: WARNING: unrecognized options: --with-freetype-dir, --with-jpeg-dir, --with-png-dir

output from step 4

array(13) {
  ["GD Version"]=>
  string(26) "bundled (2.1.0 compatible)"
  ["FreeType Support"]=>
  bool(false)
  ["GIF Read Support"]=>
  bool(true)
  ["GIF Create Support"]=>
  bool(true)
  ["JPEG Support"]=>
  bool(false)
  ["PNG Support"]=>
  bool(true)
  ["WBMP Support"]=>
  bool(true)
  ["XPM Support"]=>
  bool(false)
  ["XBM Support"]=>
  bool(true)
  ["WebP Support"]=>
  bool(false)
  ["BMP Support"]=>
  bool(true)
  ["TGA Read Support"]=>
  bool(true)
  ["JIS-mapped Japanese Font Support"]=>
  bool(false)
}

swapping the base image to php:7.3-apache

no error from docker-php-ext-configure

output from step 4

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(false)
  ["XBM Support"]=>
  bool(true)
  ["WebP Support"]=>
  bool(false)
  ["BMP Support"]=>
  bool(true)
  ["JIS-mapped Japanese Font Support"]=>
  bool(false)
}

Has there been an undocumented change to docker-php-ext-configure in 7.4?

I came accross the same issue. I could repair it by changing the line

docker-php-ext-configure gd --with-freetype-dir=/usr --with-jpeg-dir=/usr --with-png-dir=/usr

into

docker-php-ext-configure gd --with-freetype --with-jpeg

I could not find a --with-png option, but png resizing worked in my case. So maybe png support is a built in default as of PHP 7.4.

A further change I had to make was to include the libonig-dev apt package in order to compile the pdo module.

It's strange that the README.md and the description on Docker Hub don't give examples how to compile pdo and gd properly on PHP 7.4, but only give it for PHP 7.2 (which still works for 7.3 as well).

That has indeed fixed the issue. Thanks @richardbrinkman

This is a change by PHP in Version 7.4
#910 (comment)

The GD options changed by using pkg-config is explained in the upgrading document
pkg-config option changes to GD Extension

Also the upgrading document mentions in the changes to the MBSTRING extension, the following:

  • Mbstring:
    . The oniguruma library is no longer bundled with PHP, instead libonig needs
    to be available on the system. Alternatively --disable-mbregex can be used
    to disable the mbregex component.

For those building off of Debian flavored images use (libonig-devel). I found it useful to put the library in my build dependencies with the libpng library

PHP 7.4 and above

FROM wordpress:php7.4
RUN apt-get update && apt-get install -y \
    libfreetype6-dev \
    libjpeg62-turbo-dev \
    libpng-dev \
    libwebp-dev \
    libxpm-dev \
    zlib1g-dev && \
    docker-php-ext-configure gd --enable-gd --with-webp --with-jpeg \
    --with-xpm --with-freetype && \
    docker-php-ext-install -j$(nproc) gd && \
    rm -rf /var/lib/apt/lists/*