imagecreatettruecolor( ) পিএইচপি-তে একটি অন্তর্নির্মিত ফাংশন যা একটি নতুন ট্রু-কালার ইমেজ তৈরি করতে ব্যবহৃত হয়। এটি প্রদত্ত আকারের একটি ফাঁকা চিত্র প্রদান করে।
সিনট্যাক্স
resource imagecreatetruecolor($width, $height)
পরামিতি
imagecreatettruecolor() দুটি প্যারামিটার লাগে, $width এবং $উচ্চতা .
-
$প্রস্থ − $width প্যারামিটারটি ছবির প্রস্থ সেট করতে ব্যবহৃত হয়।
-
$উচ্চতা − $height প্যারামিটারটি ছবির উচ্চতা সেট করতে ব্যবহৃত হয়।
রিটার্ন মান
imagecreatettruecolor() সাফল্যের উপর একটি ইমেজ রিসোর্স শনাক্তকারী ফেরত দেয় বা এটি ত্রুটির উপর মিথ্যা ফেরত দেয়।
উদাহরণ 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);
?> আউটপুট
