imagecreatetruecolor( ) 새로운 트루 컬러 이미지를 만드는 데 사용되는 PHP의 내장 함수입니다. 주어진 크기의 빈 이미지를 반환합니다.
구문
resource imagecreatetruecolor($width, $height)
매개변수
imagecreatetruecolor() 두 매개변수, $width 사용 및 $높이 .
-
$너비 − $width 매개변수는 이미지 너비를 설정하는 데 사용됩니다.
-
$높이 − $height 매개변수는 이미지 높이를 설정하는 데 사용됩니다.
반환 값
imagecreatetruecolor() 성공 시 이미지 리소스 식별자를 반환하거나 오류 시 false를 반환합니다.
예시 1
<?php
// Set the vertices of polygon
$values = array(
150, 50, // Point 1 (x, y)
50, 250, // Point 2 (x, y)
250, 250 // Point 3 (x, y)
);
// Create the size of image or blank image
$image = imagecreatetruecolor(700, 350);
// Set the background color of image
$background_color = imagecolorallocate($image, 122, 122, 122);
// Fill background with above selected color
imagefill($image, 0, 0, $background_color);
// Allocate a color for the polygon
$image_color = imagecolorallocate($image, 0, 255, 255);
// Draw the polygon
imagepolygon($image, $values, 3, $image_color);
// Output the picture to the browser
header('Content-type: image/png');
imagepng($image);
?> 출력

예제 2 - PHP 코드 아래에 새 GD 이미지 스트림이 생성됩니다.
<?php
header ('Content-Type: image/gif');
$img = @imagecreatetruecolor(550, 220)
or die('Cannot Initialize new GD image stream');
$text_color = imagecolorallocate($img, 255, 255, 0);
imagestring($img, 10, 50, 50, 'A Simple PHP Example', $text_color);
imagepng($img);
imagedestroy($img);
?> 출력
