lorisleiva / laravel-docker

🐳 Generic docker image for Laravel Applications
MIT License
934 stars 314 forks source link

[Vote] Support JPEG images #21

Closed richstandbrook closed 4 years ago

richstandbrook commented 5 years ago

I have a test that simply calls File::image('this example.jpg') to perform an upload. However using this docker image I always get:

Error: Call to undefined function Illuminate\Http\Testing\imagejpeg()

I can see libpng-dev is installed https://github.com/lorisleiva/laravel-docker/blob/9e2f99153d824e2ed946d422259973c8868c631f/7.3/Dockerfile#L22

But libjpeg-dev isn't and also doesn't seem to exist for Alpine :/ anyone have any thoughts on this?

lorisleiva commented 5 years ago

Hi there πŸ‘‹

Thanks for reporting this. Could you please fork this and try to add the libjpeg-dev library? If that fixes your issue, I'll add it here too.

Let me now. 🀞

richstandbrook commented 5 years ago

Well I gave it a go https://github.com/richstandbrook/laravel-docker/blob/master/latest/Dockerfile#L22 but it still seems to have a problem with the same test. It can't be a fundamental problem with Laravel implementation as it works-for-meβ„’ on my local php environment and I can't find reference to the problem anywhere else. It's a strange one.

lorisleiva commented 5 years ago

Strange, sorry I've never come across this issue before. May I ask why you're using libjpeg-turbo-dev instead of libjpeg-dev?

anroots commented 5 years ago

This helped me.

https://hub.docker.com/_/php/, under "PHP Core Extensions".

RUN apt-get install -y \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/

This added JPEG support to my Dockerfile and made the imagejpeg() function missing error disappear.

lorisleiva commented 4 years ago

Thanks for sharing @anroots.

I'll try and implement this natively soon.

Feel free to open a PR if you want to speed up the process. πŸ™‚

lorisleiva commented 4 years ago

Okay so I've had to manually add exif to the 7.4 image and in my research, I saw that they simplified the process of configuring gd with RUN docker-php-ext-configure gd --with-freetype --with-jpeg. So I went ahead and decided to support JPEG for 7.4 out of the box.

I'm a bit worried about the breaking changes of backporting this to 7.2 and 7.3 so I'm not sure if I should...

lorisleiva commented 4 years ago

Okay so for the sake of consistency and to make sure all images are supporting the same extensions and features, I've added support for JPEG on 7.2 and 7.3.

It's currently building on Docker Hub and should be available in a few minutes.