imageopenpolygon()関数n PHPを使用して開いたポリゴンを描画するにはどうすればよいですか?
imageopenpolygon() は、特定の画像に開いたポリゴンを描画するために使用されるPHPの組み込み関数です。
構文
bool imageopenpolygon(resource $image,array $points,int $num_points,int $color)
パラメータ
imageopenpolygon() $ image、$ points、$ num_points、$colorの4つの異なるパラメーターを取ります。
-
$ image −作業する画像リソースを指定します。
-
$ image −作業する画像リソースを指定します。
-
$ポイント −ポリゴンのポイントを指定します。
-
$ num_points −ポイント数を指定します。 (頂点)ポイントの総数は少なくとも3つである必要があります。
-
$ color −このパラメータは、ポリゴンの色を指定します。
戻り値
imageopenpolygon() 成功した場合はTrueを返し、失敗した場合はFalseを返します。
例1
<?php
// Create a blank image using imagecreatetruecolor() function.
$img = imagecreatetruecolor(700, 300);
// Allocate a color for the polygon
$col_poly = imagecolorallocate($img, 0, 255, 0);
// Draw the polygon
imageopenpolygon($img, array(
0, 0,
100, 200,
400, 200
),
3,
$col_poly);
// Output the picture to the browser
header('Content-type: image/png');
imagepng($img);
imagedestroy($img);
?> 出力
例2
<?php
// Create a blank image using imagecreatetruecolor() function.
$image = imagecreatetruecolor(700, 300);
// allocate the colors
$blue = imagecolorallocate($image, 0, 255, 255);
// Six points of the array
$points = array(
60, 130,
130, 230,
280, 230,
350, 130,
210, 30,
60, 130
);
// Create a polygon
imageopenpolygon($image, $points, 6, $blue);
// Output to the browser
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
?> 出力
-
PHPを使用してimagecrop()関数を使用して、指定された長方形に画像をトリミングするにはどうすればよいですか?
imagecrop() は、指定された長方形に画像を切り抜くために使用されるPHPの組み込み関数です。指定された長方形の領域から画像を切り取り、出力画像を返します。指定された画像は変更されません。 構文 resource imagecrop ($image, $rect) パラメータ imagecrop() $ imageの2つのパラメータを取ります および$rect 。 $ image − imagecreatetruecolor()などの画像作成関数によって返されるパラメータです。 。画像のサイズを作成するために使用されます。 $ rect −トリミング長方形
-
PHPでimagecropauto()関数を使用して画像を自動的にトリミングするにはどうすればよいですか?
imagecropauto() はPHPに組み込まれている関数で、使用可能なモードの1つを使用して画像を自動的にトリミングするために使用されます。 構文 resource imagecropauto(resource $image, int $mode, float $threshold, int $color) パラメータ imagecropauto() 4つの異なるパラメータを取ります-$image、$ mode、$ threshold および$color 。 $ image −トリミングする画像リソースを指定します。 $ mode −これはオプションのパラメー