Convert to black and white(not grayscale) with gd library

im loading an image using

$img = imagecreatefromjpeg(‘image.jpg’);

what i want to do is convert all light pixels to white and all dark pixels to black and then output the image to the page…

can somebody pleeeease guide me on how to do this… ive found hundreds of tutorials of how to greyscale an image but i just want black and white…

pleeeeeeease

Well, this should do what you want:

header("content-type: image/jpeg");
$img = imagecreatefromjpeg('img.jpg');
imagefilter($img, IMG_FILTER_GRAYSCALE); //first, convert to grayscale
imagefilter($img, IMG_FILTER_CONTRAST, -255); //then, apply a full contrast
imagejpeg($img);

perfect… thank you very much i appreciate it :slight_smile: