I need the "color identifier" for text color which I need to pasted on an image using imagettftext(). I have found that for certain images imagecolorallocate can return false. But nowhere is indicated why this is or which colors will cause this. 8 bit is a good indicator but I can't change to a higher bit value.
Trough trial and error I found a number that works and gives a color I was looking for (between 0 - 255). That isn't really a workable solution because whenever I change the image I will again have to go look for a number that works.
$main_text_font_color = imagecolorallocate($certificate,
$font_color['red'],
$font_color['green'],
$font_color['blue']
);
imagettftext($certificate, $text_size, 0, $text_h, $text_start, $main_text_font_color, $font_url, $text);
So I would like to know if there is a way to predict which colors will cause a false and which colors will work.
Update:
So I didn't find an answer to the question but thanks to @misorude I payed attention to the first comment on the imagecolloralocate documentation page and am using a workaround mentioned in the comment. imagecolorclosest()
gives a really good approximation of the color I was looking for. jahservant13's comment also gives some nice background information on imagecolloralocate
not mentioned in the documentation.
As the color being perfect was not a requirement, this in essence is the answer I was looking for. I'm not posting this as the answer because it is not actually the answer to the question and I am still interested in knowing if there is an actual answer.