Forum Moderators: coopster

Message Too Old, No Replies

Color to Grayscale Image

All I get is garbage symbols

         

neophyte

10:03 am on Jun 10, 2008 (gmt 0)

10+ Year Member



Hello All -

I'm trying to build a little function that would take a full-color image and turn it into a grayscale image. Looking at the php manual makes this look very simple - now I'm not so sure.

When I run the script, I don't get any errors (as I'm use to seeing errors, anyway) but what I do get is a half-page of garbage symbols (i.e. ÿØÿà�JFIF������ÿþ�>CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default quality ÿÛ�C�    $.' ",#(7)... and so on).

Here's my function and it's caller. What am I missing?

Neophyte

**********************

function imageGray($fileDir, $fileName)
{

$fullPath = $fileDir . '/' . $fileName;

$im = imagecreatefromjpeg($fullPath);

imagefilter($im, IMG_FILTER_GRAYSCALE);

imagejpeg($im);

imagedestroy($im);
}

$fileDir = 'thumb';
$fileName = 'alanhead.jpg';

imageGray($fileDir, $fileName);

coopster

11:11 am on Jun 10, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You need to send out the correct content type in your headers first.

neophyte

12:15 am on Jun 11, 2008 (gmt 0)

10+ Year Member



Coopster -

Not-so-minor oversight; got it now. Thanks!

Neophyte