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);
非常感谢! –