PHPのimagestring()関数を使用してテキスト文字列画像を水平方向に描画するにはどうすればよいですか?

王林
リリース: 2023-09-05 09:52:02
転載
1198 人が閲覧しました

imagestring() は、文字列を水平方向に描画する PHP の組み込み関数です。

構文

bool imagestring($image, $font, $x, $y, $string, $color)
ログイン後にコピー

パラメータ

imagestring()は6つの異なるパラメータを受け入れます - $image、$font、$xx、$y、$string、および #$color.

  • $image - $image パラメーターは、imagecreatetruecolor() 関数を使用して空白を作成します 指定されたサイズの画像。

  • $font - $font パラメーターは、フォント サイズの値を 1、2、 3、4、5

    組み込みフォントの場合。

  • #$xxx - 水平 X 軸上の左上隅のフォントの位置を維持します。

  • $y - 垂直 Y 軸上でフォントの位置を上に維持します。

  • $string - $string パラメータは、書き込まれる文字列を保持します。

  • #$color - このパラメータは画像の色を保持します。

  • 戻り値

imagestring()

成功した場合は True を返し、失敗した場合は False を返します。 例 1

<?php
   // Create the size and image by using imagecreate() function.
   $img = imagecreate(700, 300);

   // Set the background color of the image
   $background_color = imagecolorallocate($img, 0, 0, 255);

   // Set the text color of the image
   $text_color = imagecolorallocate($img, 255, 255, 255);

   // Function to create an image that contains the string.
   imagestring($img, 50, 180, 150, "Tutorialspoint", $text_color);
   imagestring($img, 30, 160, 120, "Simply Easy Learning", $text_color);
   header("Content-Type: image/png");
   imagepng($img);
   imagedestroy($img);
?>
ログイン後にコピー

出力

PHPのimagestring()関数を使用してテキスト文字列画像を水平方向に描画するにはどうすればよいですか?例 2

<?php
   // Create the size of the image or blank image
   $img = imagecreate(700, 300);

   // Set the background color of the image
   $background_color = imagecolorallocate($img, 122, 122, 122);

   // Set the text color of the image
   $text_color = imagecolorallocate($img, 255, 255, 0);

   // Function to create an image that contains a string.
   imagestring($img, 10, 30, 60,"Tutorialspoint:Simply Easy Learning", $text_color);
   header("Content-Type: image/png");
   imagepng($img);
   imagedestroy($img);
?>
ログイン後にコピー

出力

以上がPHPのimagestring()関数を使用してテキスト文字列画像を水平方向に描画するにはどうすればよいですか?の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

関連ラベル:
ソース:tutorialspoint.com
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
最新の問題
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!