1
好吧,現在我正在嘗試做這項工作10個小時,但每分鐘我都離最終目標越來越遠......
這個東西是,我需要創建一個函數,類或任何由所選的TTF或truetype字體創建,正確調整大小,並填充圖像與URL給出的文本。圖片不應超過該文字。 我已經放棄了我所有的代碼,到目前爲止,我已經得到了最好的事情是從網上取...imagettfbbox&imagettftext - 調整大小,位置,旋轉
<?php
if(!isset($_GET['size'])) $_GET['size'] = 20;
if(!isset($_GET['text'])) $_GET['text'] = "Moj tekst";
$get_font = (isset($_GET['font'])) ? $_GET['font'] : 'arial';
$size = imagettfbbox($_GET['size'], 0, "font/".$get_font.".ttf", $_GET['text']);
$xsize = abs($size[0]) + abs($size[2]);
$ysize = abs($size[5]) + abs($size[1]);
$image = imagecreate($xsize, $ysize);
imageSaveAlpha($image, true);
ImageAlphaBlending($image, false);
$transparentColor = imagecolorallocatealpha($image, 200, 200, 200, 127);
Imagefill($image, 0, 0, $transparentColor);
$blue = imagecolorallocate($image, 0, 0, 255);
$white = ImageColorAllocate($image, 255,255,255);
$black = ImageColorAllocate($image, 0,0,0); //-($_GET['size']/20)
imagettftext($image, $_GET['size'], 0, abs($size[0]), abs($size[5]), $black, "font/".$get_font.".ttf", $_GET['text']);
header("content-type: image/png");
imagepng($image);
imagedestroy($image);
?>
此代碼是確定的,雖然最後還是第一後的邊緣有時會部分隱藏,或者只是它不適合創建的圖像(取決於字體大小),這不是小字體大小的問題。而功能我真正需要的是通過改變圖像的旋轉來改變整個圖像的比例,使文本在適合
例:http://img199.imageshack.us/img199/9368/32739521.jpg
此外,如果有要完成的功能或類,這樣做,這將是偉大的..:'(:)