Posts Learn Components Snippets Categories Tags About
/

How to get plain base64 encoded image format in Laravel

Learn how to get plain base64 image format in Laravel with the help of Laravel Intervention package

Created on Aug 22, 2021

18 views

To get a plain base64 image format in Laravel you can make use of the Laravel Intervention package. The steps are very simple which you only have to call the "encode()" method and access the "encoded" property.
$location = Storage::disk('public')->url(Post::first()->poster);

$image = Image::make($location)->encode()->encoded;

base64_encode($image);
By doing so the image that's returned is plain base64 format. If you want to get the formatted base64 format that you can straight away attach to an image tag, you can refer to the previous code snippets on Intervention Image encode image to base64 format in Laravel

Snippets by

PostSrc poster

PostSrc

Full stack developer mainly focusing on the front end side of the web. The main author of PostSrc and loves writing tutorial and guides online.

new

PostSrc Code Components

Collection of Tailwind CSS components for everyone to use. Browse all of the components that's right for your project.

View Components

Other Code Snippets

More