Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ldiebold's avatar

Displaying images with Intervention Image

I'm trying to display pictures on a page using this tutorial: https://laracasts.com/lessons/laravel-image-manipulation

The page displays a blank screen and I can't figure out how to get it working.

I tried the examples on http://image.intervention.io/use/http but the result is a bunch of weird symbols like question marks and @ signs.

Any ideas?

0 likes
5 replies
grusch-it's avatar

I have no idea - sorry.

And yep...you really don't need to provide any code samples showing what you tried to do so far.

sukonovs's avatar

Looks like you browser is displaying binary data instead of rendering image, probably invalid header information. Is there real reason to stream image instead of saving and linking?

ldiebold's avatar

Hi sukonovs, I'm trying to add watermarks to my images and using intervention image seemed like the best way to do it.

Here's what I tried (First time using codeblocks so hopefully it will come out okay!):

This gives me a blank screen

Route::get('/', function()
{

    $image = Image::make(file_get_contents('http://images.boomsbeat.com/data/images/full/979/justin-bieber-2013-3226-hdwallfan-jpg.jpg'));

    return Response::make($image, 200, ['Content-Type' => 'image/jpg']);

});

This gives me weird text like the following "�PNG  IHDR X�v�p pHYs���+ kIDATx���1 ������$ �v" It should be a red rectangle. playing around with the dimensions makes it work sometimes... weird.

Route::get('/', function()
{
// create a new image resource
    $img = Image::canvas(800, 600, '#ff0000');

// send HTTP header and output image data
    header('Content-Type: image/png');
    echo $img->encode('png');
});

Next time I'll post examples in the first place :).

1 like
cipsas's avatar
cipsas
Best Answer
Level 10

I think you should return:

 return $img->response('png');
1 like
ldiebold's avatar

Thanks cipsas! Just realized that the answer was written under the Laracast video. Thanks everyone for the help!

Please or to participate in this conversation.