1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| <?php
function og($title, $des) { $img = imagecreatefrompng('./bg.png'); $black = imagecolorallocate($img, 0, 0, 0); $title_font = './ZhanKuKuaiLeTi2016XiuDingBan-1.ttf'; $desc_font = './ZhanKuKuaiLeTi2016XiuDingBan-1.ttf'; $title_lines = explode("\n", wordwrap($title, 30, "\n", true)); $desc_lines = explode("\n", wordwrap($des, 60, "\n", true)); $title_y = 60; $desc_y = 200;
foreach ($title_lines as $line) { imagettftext($img, 55, 0, 10, $title_y, $black, $title_font, $line); $title_y += 65; }
foreach ($desc_lines as $line) { imagettftext($img, 25, 0, 10, $desc_y, $black, $desc_font, $line); $desc_y += 30; }
header('Content-Type: image/png'); imagepng($img); imagedestroy($img); }
$title = isset($_GET['title']) ? $_GET['title'] : 'Default Title'; $des = isset($_GET['des']) ? $_GET['des'] : 'Default Description';
og($title, $des); ?>
|