php - imagettftext not working for me -
i have function takes images , combines them single wide image. seems work. trying put text on images , not.
the 5 lines after: // allocate color text, ones added create text. there i'm missing? don't see errors when run code.
function merge($filename_w, $filename_x, $filename_y, $filename_z,$filename_result, $text) { // dimensions specified images list($width_w, $height_w) = getimagesize($filename_w); list($width_x, $height_x) = getimagesize($filename_x); list($width_y, $height_y) = getimagesize($filename_y); list($width_z, $height_z) = getimagesize($filename_z); // create new image desired dimensions $image = imagecreatetruecolor($width_w + $width_x + $width_y + $width_z, $height_x); // load images , copy destination image $image_w = imagecreatefromjpeg($filename_w); $image_x = imagecreatefromjpeg($filename_x); $image_y = imagecreatefromjpeg($filename_y); $image_z = imagecreatefromjpeg($filename_z); imagecopy($image, $image_w, 0, 0, 0, 0, $width_w, $height_w); imagecopy($image, $image_x, $width_w, 0, 0, 0, $width_x, $height_x); imagecopy($image, $image_y, $width_w + $width_x, 0, 0, 0, $width_y, $height_y); imagecopy($image, $image_z, $width_w + $width_x + $width_y, 0, 0, 0, $width_z, $height_z); // allocate color text $white = imagecolorallocate($image, 255, 255, 255); // set path font file $font_path = './tahoma.ttf'; // print text on image imagettftext($image, 25, 0, 75, 300, $white, $font_path, "test text"); // save resulting image disk (as jpeg) imagejpeg($image, $filename_result); // clean imagedestroy($image); imagedestroy($image_w); imagedestroy($image_x); imagedestroy($image_y); imagedestroy($image_z); }
Comments
Post a Comment