Intervention Image - saving in a variable in base64 encoded format

I am using Laravel with the Intervention Image processing package .

I want to save the cropped image to a variable, and then to the database, but I can not find in the documentation how to export the result as a string. Here is my code:

$img = Image::make($uploadedImage);
$img->crop(160, 210);
$imageEncoded = // ?

There save(), but it saves only the file.

How to export a modified intrusion image to a string variable? ( data:image/jpeg;base64,…)

+4
source share
1 answer

You can use encode for this.

$data = (string) Image::make('public/bar.png')->encode('data-url');
+7
source

Source: https://habr.com/ru/post/1614875/


All Articles