I'm having issues incorporating imagefilter in the following. Output is a color image. I've tried a few different options, based on php.net documentation but I either get a black image or a color image, not grayscale.
$data = file_get_contents($_FILES['image']['tmp_name']);
$vImg = imagecreatefromstring($data);
$dstImg = imagecreatetruecolor($nw, $nh);
imagefilter($dstImg, IMG_FILTER_GRAYSCALE); // imagefilter added
imagecopyresampled($dstImg, $vImg, 0, 0, $x1, $y1, $nw, $nh, $w, $h);
imagejpeg($dstImg, $path);
imagedestroy($dstImg);
I know my usage is complete wrong, so any help would be much appreciated!