PHP
 Computer >> コンピューター >  >> プログラミング >> PHP

PHPでimagestringup()関数を使用して文字列を垂直に描画するにはどうすればよいですか?


imagestringup() は、画像を垂直方向に描画するために使用されるPHPの組み込み関数です。

構文

bool imagestringup ($image, $font, $x, $y, $string, $color)

パラメータ

imagestring() $ image、$ font、$ x、$ y、$ string、$colorの6つのパラメータを受け入れます。

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

  • $ font − $ fontパラメータは、 imageloadfont()に登録されている組み込みフォントまたはその他のフォント識別子のフォントサイズ値を1、2、3、4、および5に設定するために使用されます。 機能。

  • $ x −フォントの水平X軸、左上隅の位置を保持します。

  • $ y −垂直Y軸の最上部の隅にあるフォントの位置を保持します。

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

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

戻り値

imagestring() 成功した場合はTrueを返し、失敗した場合はFalseを返します。

<?php
   // Create a 250*190 image using imagecreatetruecolor() function
   $img = imagecreatetruecolor(700, 300);

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

   // Fill background with above-selected color
   imagefill($img, 0, 0, $bgcolor);

   // Write the white color text
   $textcolor = imagecolorallocate($img, 255, 255, 255);
   imagestringup($img, 6, 130, 150, 'Hello World', $textcolor);

   // Output the picture to the browser
   header('Content-type: image/png');
   imagepng($img);
?>

出力

PHPでimagestringup()関数を使用して文字列を垂直に描画するにはどうすればよいですか?


  1. PHPのimagecreatefromjpeg()関数を使用してJPEGファイルから新しい画像を作成するにはどうすればよいですか?

    imagecreatefromjpeg() は、JPEGファイルから新しい画像を作成するために使用されるPHPの組み込み関数です。指定されたファイル名から取得した画像を表す画像識別子を返します。 構文 resource imagecreatefromjpeg(string $filename) パラメータ imagecreatefromjpeg() $ filenameという1つのパラメータのみを使用します 、画像の名前またはJPEG画像へのパスを保持します。 戻り値 imagecreatefromjpeg() 成功すると画像リソース識別子を返し、falseではエラーを返します。 例

  2. PHPのimagecreate()関数

    imagecreate()関数は、新しい画像を作成するために使用されます。 imagecreate()の代わりにimagecreatetruecolor()を使用して画像を作成することをお勧めします。これは、imagecreatetruecolor()を使用して作成できる可能な限り最高品質の画像で画像処理が行われるためです。 構文 imagecreate( $width, $height ) パラメータ 幅 :画像の幅 高さ :画像の高さ 戻る imagecreate()関数は、成功した場合は画像リソース識別子を返し、エラーの場合はFALSEを返します。 例 次に例を示しま