0
我想從一個字符串創建一個圖像,並且能夠使用這個圖像作爲我生成的pdf的背景。如何創建未知寬度和高度的圖像?
這幾乎不是問題。我想要生成的圖像是一個全尺寸的圖像,我知道有兩個選擇:
第一:說圖像有一個固定的大小,並找到一種方式來說,名稱必須是全尺寸(圖像創建是從圖像左下角開始,旋轉45°的文字)。
其次:說圖像有不同的大小取決於名稱使用的大小。
我不知道我是否清楚自己,但如果有人有任何想法,請讓我知道!
PS:這是我的時刻代碼:
// Création de l'image
$im = imagecreatetruecolor();
// Création de quelques couleurs
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 240, 240, 240);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 400, 500, $white);
// Le texte à dessiner
$text = $this->user->data->display_name;
// Définition de la variable d'environnement pour GD
putenv('GDFONTPATH=' . realpath('.'));
// Remplacez le chemin par votre propre chemin de police
$font = 'arial.ttf';
// Ajout du texte
imagettftext($im, 100, 45, 100, 500, $grey, $font, $text);
// Utiliser imagepng() donnera un texte plus claire,
// comparé à l'utilisation de la fonction imagejpeg()
$this->watermark = 'watermark/'.date('Y-m-d-H-i-s').'.png';
imagepng($im, $this->watermark);
imagedestroy($im);
非常感謝! –