I'm trying to follow this example to generate an image with dynamic text.
I wanted to change the size of the font, I put even 100 instead of 4, but it still appears same as before.
I'm not very good at PHP. Any sort of help would be appreciated.
Here's an example how small it appears :(
Here's my example code -
$font = 'arial.ttf'; //FONT SIZE
$width = imagefontwidth($font) * strlen($string) ;
$height = imagefontheight($font) ;
$im = imagecreatefrompng($imageO);
$x = imagesx($im) / 2; //PLACEMENT CENTERISH – X
$y = imagesy($im) / 2; //PLACEMENT CENTERISH – Y
// $backgroundColor = imagecolorallocate ($im, 255, 255, 255);
$transparency = 25;
imagesavealpha($im, true);
$background = imagecolorallocatealpha($im, background_r, background_g, background_b, $transparency);
$textColor = imagecolorallocate ($im, 0,0,0);
imagestring ($im, $font, $x, $y, $string, $textColor);
imagepng($im,$imageN[$k]);
$w = imagesx($im);
$h = imagesy($im);
Thanks
ADDED LATER
Ok now here it is what I have done but as a result, no text is visible in the callout box.
$font = 'arial.ttf'; //YOUR FONT SIZE
$im = imagecreatefrompng($imageO);
$string = "My Text";
$imageN ="NewImage.png";
$transparency = 25;
imagesavealpha($im, true);
$background = imagecolorallocatealpha($im, background_r, background_g, background_b, $transparency);
$textColor = imagecolorallocate ($im, 0,0,0);
//imagestring ($im, 5, $x, $y, $string, $textColor);
imagettftext($im, 36, 0, 10, 20, $textColor, $font, $string);
imagepng($im,$imageN);
See Question&Answers more detail:os