Search code examples
phpimagegd2

Picture display with PHP


I've a problem with some lines of code. I try to generate a picture with php and the gd2 librarie.

<?php

header('Content-type: image/jpeg');

$im = imagecreatefromjpeg('profil.jpg');
imagejpeg($im);

imagedestroy($im);?>

This code doesn't work. There's no image displayed, just a message : "this image can't be displayed because there's error" displayed in white on grey background.

The picture is well loaded and "$im" is a resource created with "imagecreatefromjpeg"...

If i remove all lines except header('Content-type: image/jpeg');, I've got the same problem.

Who can give me the right way ??

Thanks by advance !

Mickael


Solution

  • Working good after creating a new php file where I pasted my code.

    I think that my file was corrupt.