Open byCedric opened 5 years ago
I'm getting this same error with circle ci. Everything worked until I created a test to test an image upload. Now its failing:
1) Tests\Feature\Feature\InvoiceTemplateTest::proUserCanCreateAnInvoiceTemplateWithAnImage
Error: Call to undefined function Illuminate\Http\Testing\imagejpeg()
/root/repo/vendor/laravel/framework/src/Illuminate/Http/Testing/FileFactory.php:55
/root/repo/vendor/laravel/framework/src/Illuminate/Support/helpers.php:1027
/root/repo/vendor/laravel/framework/src/Illuminate/Http/Testing/FileFactory.php:63
/root/repo/vendor/laravel/framework/src/Illuminate/Http/Testing/FileFactory.php:34
/root/repo/tests/Feature/InvoiceTemplateTest.php:98
I also added the following to my config.yml and it hasn't fixed it:
- run:
name: Install GD Library
command: apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && docker-php-ext-install -j$(nproc) gd
lol wow, the solution was to change the image from a .jpg to a .png. Now it works.
Make sure you have libpng-dev
& libjpeg-dev
installed then do this
RUN docker-php-ext-configure gd \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-zlib-dir
Read the official PHP documentation
JefferyHus's answer solves the problem. For alpine docker user, install this
RUN apk add --no-cache \
libpng-dev \
libjpeg-turbo \
libjpeg-turbo-dev
RUN docker-php-ext-configure gd \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-zlib-dir
lol wow, the solution was to change the image from a .jpg to a .png. Now it works.
I don't think this is good solution in long term
Not sure what I'm doing wrong but after messing around quite a bit with @kenng 's solution for alpine containers I'm still getting this:
configure: error: unrecognized options: --with-gd, --with-jpeg-dir, --with-png-dir, --with-zlib-dir
ERROR: Service 'php' failed to build: The command '/bin/sh -c docker-php-ext-configure gd --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir' returned a non-zero code: 1
Dockerfile
FROM php:7.4-fpm-alpine
RUN apk add --no-cache bash curl vim zip \
zlib-dev \
php7-zlib \
libpng-dev \
libjpeg-turbo \
libjpeg-turbo-dev
RUN docker-php-ext-install pdo pdo_mysql gd
RUN docker-php-ext-configure gd \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-zlib-dir
WORKDIR /var/www/html
Any thoughts on why it's not letting me run the configuration? or rather why these are 'unrecognized options'?
@dfoster-cb911
Following on @JefferyHus reply
if you have PHP 7.4 or above you just need RUN docker-php-ext-configure gd --enable-gd --with-jpeg
according to the PHP documentation. Sill, don't forget to have libjpeg-dev
and libpng-dev
installed.
EDIT:
It still didn't work for me. I found out you need to configure gd before installing it
FROM php:7.4-apache
RUN apt-get update && apt-get install -y libjpeg-dev libpng-dev
RUN docker-php-ext-configure gd --enable-gd --with-jpeg
RUN docker-php-ext-install gd
FROM php:7.4-apache
RUN apt-get update && apt-get install -y libjpeg-dev libpng-dev
RUN docker-php-ext-configure gd --enable-gd --with-jpeg
RUN docker-php-ext-install gd
Working for me! Thanks.
Description of the bug
Today I tried to create a test for uploading certain images using this guide. Unfortunately, it appears that the laravel uploaded file faker is not picking up on PHP GD properly.
Actual behavior