Home / Snippets / How to get plain base64 encoded image format in Laravel
How to get plain base64 encoded image format in Laravel cover

How to get plain base64 encoded image format in Laravel

561

2 years ago

0 comments

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
notion avatar

Ahabz

Week-end developer currently experimenting with web, mobile, and all things programming.

Topics:

Frontend

Resource

Average

Average

Support Us

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

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this