I`m working on a script that posts tweets to twitter with a random generated image with a random background color. Thats working perfectly but I want to show the rgb colors in the center of the image but its not working right. This is my code:
$rgbColor = array(rand(0,255),rand(0,255),rand(0,255));
$image = imagecreatetruecolor(600, 200);
$color = imagecolorallocate($image, $rgbColor[0], $rgbColor[1], $rgbColor[2]);
$white = imagecolorallocate($image, 255, 255, 255);
$black = imagecolorallocate($image, 0, 0, 0);
imagefill($image, 0, 0, $color);
imagettftext($image, 20, 0,(300-(strlen('rgb('.$rgbColor[0].', '.$rgbColor[1].', '.$rgbColor[2].')')*20)/2), 75, (brghtdiff($rgbColor[0], $rgbColor[1], $rgbColor[2]) > 125 ? $black : $white), './Station.ttf', 'rgb('.$rgbColor[0].', '.$rgbColor[1].', '.$rgbColor[2].')');
imagejpeg($image, './image.jpg');
imagedestroy($image);
Creates:
Well, it displays the rgb(int, int, int) not in the center, does anyone know how the text can be in the center?