इमेजसेटस्टाइल () PHP में एक इनबिल्ट फंक्शन है जिसका उपयोग लाइन ड्राइंग के लिए स्टाइल सेट करने के लिए किया जाता है। इसका उपयोग imagepolygon . जैसे सभी रेखा आरेखण कार्यों द्वारा किया जा सकता है या इमेजलाइन ।
सिंटैक्स
bool imagesetstyle(resource $image, array $style)
पैरामीटर
इमेजसेटस्टाइल () दो पैरामीटर लेता है:$छवि और $शैली ।
-
$छवि - काम करने के लिए छवि संसाधन निर्दिष्ट करता है।
-
$शैली − पिक्सेल रंगों की सरणी निर्दिष्ट करता है।
रिटर्न वैल्यू
इमेजसेटस्टाइल () सफलता पर सही या असफलता पर गलत लौटाता है।
उदाहरण 1
<?php
header("Content-type: image/jpeg");
$img = imagecreatetruecolor(700, 300);
$w = imagecolorallocate($img, 122, 122, 122);
$red = imagecolorallocate($img, 255, 0, 0);
/* Draw a dashed line, 5 red pixels, 5 white pixels */
$style = array($red, $red, $red, $red, $red, $w, $w, $w, $w, $w);
imagesetstyle($img, $style);
imageline($img, 0, 0, 200, 200, IMG_COLOR_STYLED);
/* Draw a line of happy faces using imagesetbrush() with imagesetstyle */
$style = array($w, $w, $w, $w, $w, $w, $w, $w, $w, $w, $w, $w, $red);
imagesetstyle($img, $style);
$brush = imagecreatefrompng('C:\xampp\htdocs\Images\img34.png');
$w2 = imagecolorallocate($brush, 255, 255, 255);
imagecolortransparent($brush, $w2);
imagesetbrush($img, $brush);
imageline($img, 200, 0, 0, 200, IMG_COLOR_STYLEDBRUSHED);
imagejpeg($img);
imagedestroy($img);
?> इनपुट छवि

आउटपुट छवि

उदाहरण 2
<?php
// Load the png image using imagecreatefrompng() function.
$img = imagecreatefrompng('C:\xampp\htdocs\Images\img34.png');
// Allocated the blue and green colors
$blue = imagecolorallocate($img, 0, 0, 255);
$green = imagecolorallocate($img, 0, 255, 0);
// Draw a dashed line, 5 blue pixels, 5 white pixels
$style = array($blue, $blue, $blue, $blue, $blue, $green, $green, $green, $green, $green);
imagesetstyle($img, $style);
imageline($img, 0, 100, 800, 100, IMG_COLOR_STYLED);
// Output image to the browser
header('Content-type: image/png');
imagepng($img);
?> आउटपुट
