I'm trying to add some features to PHP GD installation. I'm using Docker PHP "Official" release as base (php:7.1.15-fpm-jessie).
My current production environment uses CentOS, which GD module comes with FreeType, JPEG and PNG support, as you can see in the phpinfo output:
GD Support => enabled
GD headers Version => 2.2.5
GD library Version => 2.2.5
FreeType Support => enabled
FreeType Linkage => with freetype
FreeType Version => 2.4.11
GIF Read Support => enabled
GIF Create Support => enabled
JPEG Support => enabled
libJPEG Version => 6b
PNG Support => enabled
libPNG Version => 1.5.13
WBMP Support => enabled
XPM Support => enabled
libXpm Version => 30411
XBM Support => enabled
WebP Support => enabled
Directive => Local Value => Master Value
gd.jpeg_ignore_warning => 1 => 1
But this Docker image comes without FreeType and JPEG support and with a much older version of GD (see phpinfo bellow):
GD Support => enabled
GD Version => bundled (2.1.0 compatible)
GIF Read Support => enabled
GIF Create Support => enabled
PNG Support => enabled
libPNG Version => 1.2.50
WBMP Support => enabled
XBM Support => enabled
Directive => Local Value => Master Value
gd.jpeg_ignore_warning => 1 => 1
Do I need to recompile PHP or just the extension? The image uses Debian Jessie.
EDITION (SOLUTION):
After recompiling I found the best solution in this post:
So I simply added:
RUN apt-get update && apt-get install libgd3 libgd-dev && rm -rf /var/lib/apt/lists/*
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
RUN docker-php-ext-install -j$(nproc) gd
After that my phpinfo start to show:
GD Support => enabled
GD Version => bundled (2.1.0 compatible)
FreeType Support => enabled
FreeType Linkage => with freetype
FreeType Version => 2.5.2
GIF Read Support => enabled
GIF Create Support => enabled
JPEG Support => enabled
libJPEG Version => 6b
PNG Support => enabled
libPNG Version => 1.2.50
Add this to your Dockerfile:
RUN apt-get update && apt-get install -y libpng-dev
RUN apt-get install -y \
libwebp-dev \
libjpeg62-turbo-dev \
libpng-dev libxpm-dev \
libfreetype6-dev
RUN docker-php-ext-configure gd \
--with-gd \
--with-webp-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib-dir \
--with-xpm-dir \
--with-freetype-dir \
--enable-gd-native-ttf
RUN docker-php-ext-install gd
It works for me.