How to Use Intervention Image When Setting Up Laravel Environment with Docker
Thank you for your continued support.
This article contains advertisements that help fund our operations.
Table Of Contents
⇨ Click here for the table of contents for Laravel articles
I summarized how to use Intervention Image when setting up Laravel environment with Docker.
Implementation Environment
docker-compose Version
version: "3"
Dockerfile for Application Container
FROM php:7.4-fpm-buster
Error Messages Resolved in This Article
Unable to init from given binary data.
Webp format is not supported by PHP installation.
How to Use Intervention Image
Please add these packages to the Dockerfile for the application container.
RUN apt-get update
RUN apt-get install -y zlib1g-dev libpng-dev libjpeg-dev libfreetype6-dev libwebp-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp \
&& docker-php-ext-install gd
Explanation
To use Intervention Image, you must install the image processing library called gd.
When setting up a Laravel project locally without using Docker, you can use GD without any issues by installing it. However, when setting up the environment with Docker, errors related to compression formats such as jpeg and webp occurred.
To resolve them:
docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp
You need to specify options with --with like this, and to use them, you need to install
libjpeg-dev libfreetype6-dev libwebp-dev
using apt-get.
By following the solution mentioned earlier, it started working.
How to Implement Intervention Image
For the implementation method, please refer to this article.
⇨【Laravel】Intervention Image: Convenient for Processing and Compressing Images
⇨Compress Images to webp Using Intervention Image in Laravel
Conclusion
That's it. I hope it can be helpful to someone.
This blog is supported by ad clicks. Thank you.
That's all!
Popular Articles