Search code examples
phpgdphp-gd

php gd GRAYSCALE


i have a code in php with the GD library and it gives error

here is the code :

<?php
    header('content-type: image/png');
    $image = imagecreatefrompng('a.png');
    imagefilter($image, IMG_FILTER_GRAYSCALE);
    imagepng($image);
    imagedestroy($image);
?>

and here is the error :

the image localhost/image/gdimg.php cannot displayed because it contains errors

what is wrong here?


Solution

  • remove line

    header('content-type: image/png');
    

    and you will see php error.