Posts Learn Components Snippets Categories Tags Tools new 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

63 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

If you like our tutorial, do make sure to support us by being our Patreon or buy us some coffee ☕️

)