文字列から画像を作成し、この画像を生成しているpdfの背景として使用できるようにしたいと考えています。
これはほとんど問題になりません。生成された画像をフルサイズの画像にしたいのですが、2つの選択肢があることを知っています:
最初に: 画像は固定サイズであると言い、名前がフルサイズでなければならないことを示す方法を見つけます (作成された画像は、画像の左下端から始まる 45° 回転のテキストです)。
2 番目 : 名前で使用されるサイズに応じて、画像のサイズがさまざまであるとします。
私が自分自身を明確にしたかどうかはわかりませんが、誰かが知っているなら教えてください!
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);