I have an image of a bar code, and I want to change the black color to any other color that is more colorful. How can I do it in PHP?
If your image is monochrome then you can use the imagefilter()
function:
$image = imagecreatefromjpeg('filename.jpg');
imagefilter($image, IMG_FILTER_COLORIZE, 0, 0, 255); // make it blue!
imagejpeg($image, 'filename.jpg');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With