Reputation: 1131
Everything seems to be working as I do not get any error but I get garbage code instead of the image itself. The code is very simple in the controller:
// get image & resize
$img = ImgMgr::make('http://pathToImage.jpg')->resize(200,100);
// send HTTP header and output image data
echo $img->response('jpg', 70);
Then I get : HTTP/1.0 200 OK Cache-Control: no-cache, private Content-Length: 2900 Content-Type: image/jpeg Date: Wed, 21 Jul 2021 16:05:21 GMT ����JFIF``��;CREATOR: gd-jpeg v1.0 (using IJG JPEG v90), quality = 70 ��C #%$""!&+7/&)4)!"0A149;>>>%.DIC;��C ;("(;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;��dd"��
What am I missing?
Upvotes: 0
Views: 740
Reputation: 11
Here is the solution...
$img = ImgMgr::make('http://pathToImage.jpg')->resize(200,100);
$img->response('jpg', 70);
$type = 'png';
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($img);
<img src="{!! $base64 !!}">
Upvotes: 1