php - GD library create image with dynamic text on it -


i want place text generated dynamically sql select, on image created gd library. i'm using create image , place text on it, want place variable $users sql select data image:

$query = "select id, name users .... order id desc"; while ($line = mysql_fetch_assoc($query)) {    $users .=  "<img src='https://www.domain.com/" . $line['id'] . "/photo'/>&nbsp;" . $line['name'] . "<br />"; }    function  create_image(){     $im = @imagecreate(550, 600)or die("cannot initialize new gd image stream");     $background_color = imagecolorallocate($im, 255, 255, 0);  // yellow     $red = imagecolorallocate($im, 255, 0, 0);      // red      imagestring($im, 1, 5,  10, $users);     imagestring($im, 2, 5,  50, "text 2", $red);      imagepng($im,"image.png");     imagedestroy($im); }  create_image(); print "<img src=image.png?".date("u").">"; 

the text in $user variable not appear, how can this?

thanks

here example how draw text on png image:

$img = imagecreatefrompng($image_path); //$image_path -> on text drawn         @imagealphablending($img, true);         @imagesavealpha($img, true); $textcolor = imagecolorallocate($img, 100, 100, 98); $font = '../fonts/arial.ttf';  imagettftext($img, 18, 0, 140, 285,$textcolor,$font, $name); // $name -> dynamic text drawn on image $path = "path want save created image";  $image = imagejpeg($img, $path); imagedestroy($img); 

done..


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -