Search code examples
phpimageheadercontent-typeimagefilter

PHP ImageFilter


I have writen a small script to go in a Facebook App that can filter images for you. I am having trouble with the GRAYSCALE filter It seems to only display what I think is byte code for the image, instead of the image. I think this may have something to do with the headers and content type. I need to display the image filtered by PHP with this code:

header("content-type: image/jpeg");
$image = imagecreatefromjpeg("http://majik.zbrowntechnology.info/upload/zbt_1794056140.jpg");
imagefilter($image, IMG_FILTER_GRAYSCALE);
imagepng($image);
imagedestroy($image, 'test.jpg');

on an HTML page. Any ideas?


Solution

  • You set Content-Type to image/jpeg but send a PNG image.

    header("Content-Type: image/jpeg");
    imagejpeg($image);
    

    This should work.

    BTW: imagedestroy() only has one argument