<?php
$file = '/var/www/examples/heroine.png';
$im = imagecreatefrompng($file);
imagefilter($im, IMG_FILTER_GRAYSCALE);
imagePng($im, '/tmp/image.png');
/var/www/examples/heroine.png
- path to image to grayscaleimagecreatefrompng
- creates lib:GD image object from given PNG imageimagefilter
- applies filter to imageIMG_FILTER_GRAYSCALE
- converts colors for our image to grayscaleimagePng
- saves image in PNG format to the given path
group: filter
<?php
$file = '/var/www/examples/heroine.png';
$im = imagecreatefrompng($file);
imagefilter($im, IMG_FILTER_GRAYSCALE);
imagepng($im, '/tmp/image.png');