Image Manipulation On The Fly with Laravel

Suko Widodo
2 min readSep 28, 2021

--

Almost 2 year ago i used cloudinary for managing all my web or mobile application’s media assets in the cloud. Cloudinary provide sdk for any programming language and easy for implemented.

Cloudinary offers an end-to-end solution for all your image and video needs, including upload, storage, administration, manipulation and delivery. Media upload, processing, and delivery are done on Cloudinary’s servers and automatically scale for handling high load and bursts of traffic.

I really like image manipulation which exist in cloudinary. It is very helpfull because we can resize image size without any effort with constraint size. It just need to be change path on the url.

In this tutorial i want to share about my experience create image manipulation like feature have been in cloudinary with laravel.

So what benefit when using this manipulation feature?

  1. Reduce size image size provided to client.
  2. Flexible manipulate dimention of image
  3. Original file not has been changed

I used library intervention for this tutorial. Intervention Image is a PHP image handling and manipulation library providing an easier and expressive way to create, edit, and compose images. The package includes ServiceProviders and Facades for easy Laravel integration.

Oke let get started, create new routing in your router laravel like below with parameter name of image, size and width.

Now you can access your image like this http://127.0.0.1:8000/image_manipulaton/20210912165732.png?width=100&height=200 and you can change your manipulate option see this according your needed. I hope this can help and thank you.

--

--