imagecreatetruecolor( ) PHP में एक इनबिल्ट फंक्शन है जिसका उपयोग एक नई ट्रू-कलर इमेज बनाने के लिए किया जाता है। यह दिए गए आकार की एक खाली छवि देता है।
सिंटैक्स
resource imagecreatetruecolor($width, $height)
पैरामीटर
imagecreatetruecolor() दो पैरामीटर लेता है, $चौड़ाई और $ऊंचाई ।
-
$चौड़ाई − $width पैरामीटर का इस्तेमाल इमेज की चौड़ाई सेट करने के लिए किया जाता है.
-
$ऊंचाई − $height पैरामीटर का इस्तेमाल इमेज की ऊंचाई सेट करने के लिए किया जाता है।
रिटर्न वैल्यू
imagecreatetruecolor() सफलता पर एक छवि संसाधन पहचानकर्ता देता है या यह त्रुटियों पर गलत लौटाता है।
उदाहरण 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);
?> आउटपुट
