Hi all,
I have a collection of black and white JPEG's stored on my server. These images are symbol based, where the symbol is a collection of black lines on a white background.
I am trying to use GD to replace the black colour with another colour on the fly based on a variable passed. Currently, I am:
Getting the JPEG as: $image = imagecreatefromjpeg($imgURL), Converting a HEX code (#FF0000, say) to RGB through PHP,
And then feeding these variables to:
private function colourize_image($image, $colour, $contrast = 0) {
if (!$image) { return false; }
imagealphablending($image, true);
imagesavealpha($image, true);
# Convert hex colour into RGB values
$r = hexdec('0x' . $colour{0} . $colour{1});
$g = hexdec('0x' . $colour{2} . $colour{3});
$b = hexdec('0x' . $colour{4} . $colour{5});
imagefilter($image, IMG_FILTER_COLORIZE, $r, $g, $b);
imagefilter($image, IMG_FILTER_CONTRAST, $contrast);
# Return the GD image object
return $image;
}
For some reason, the function doesn't work at all (it won't overlay a new colour).
Can anyone advise as to where I am going wrong?
Many thanks.