PHP 生成獎狀

最閒的碼農發表於2019-07-12
ob_clean();
$realname = "姓名:最閒的碼農";
$schoolname = "社群:Laravel"; 

$image = imagecreatefrompng('1562926506930.png');      //書模版圖片檔案的路徑 必須是png格式的檔案
$red = imagecolorallocate($image,00,00,00); // 字型顏色
// imageTTFText("Image", "Font Size", "Rotate Text", "Left Position","Top Position", "Font Color", "Font Name", "Text To Print");
//根據文字填寫的位置不同
//"Left Position 和 Top Position 可以使用 getimagesize進行配合計算文字x和y軸座標
imageTTFText($image, 50, 0, 628, 615, $red, 'simheittf.ttf',$realname);
imageTTFText($image, 50, 0, 628, 714, $red, 'simheittf.ttf', $schoolname);
header('Content-type: image/png;');
ImagePng($image);
imagedestroy($image);
$filename = 'certificate_aadarsh.png';
ImagePng($image, $filename);
imagedestroy($image);

WechatIMG3.jpeg
PHP 生成獎狀

相關文章