문제

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?

도움이 되었습니까?

해결책

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

다른 팁

The script works fine for me, I see the grayscaled image(even with the wrong parts listed above)

If you see there the source I would guess at first, that there is any output before the headers can be sent. Set error_reporting to E_ALL, so you can see if and where there is some unintended output.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top