इमेजलाइन () PHP में एक इनबिल्ट फ़ंक्शन है जिसका उपयोग दो दिए गए बिंदुओं के बीच एक रेखा खींचने के लिए किया जाता है।
सिंटैक्स
bool imageline(resource $image, int $x1, int $y1,int $x2, int $y2, int $color)
पैरामीटर
इमेजलाइन () छह अलग-अलग पैरामीटर लेता है:$image, $x1, $y1, $x2, $y2 और $color.
-
$छवि - काम करने के लिए छवि संसाधन निर्दिष्ट करता है।
-
$x1 - आरंभिक x-निर्देशांक निर्दिष्ट करता है।
-
$y1 - आरंभिक y-निर्देशांक निर्दिष्ट करता है।
-
$x2 - अंतिम x-निर्देशांक निर्दिष्ट करता है।
-
$y2 - अंतिम y-निर्देशांक निर्दिष्ट करता है।
-
$रंग - imagecolorallocate() . का उपयोग करके बनाए गए लाइन रंग और रंग पहचानकर्ता को निर्दिष्ट करता है समारोह।
रिटर्न वैल्यू
इमेजलाइन () सफलता पर सही है या विफलता पर गलत है।
उदाहरण 1 - इमेज में लाइन जोड़ें
<?php
// Create an image using imagecreatefrompng() function
$img = imagecreatefrompng('C:\xampp\htdocs\test\515.png');
// allocated the line color
$text_color = imagecolorallocate($img, 255, 255, 0);
// Set the thickness of the line
imagesetthickness($img, 5);
// Add a line using imageline() function.
imageline($img, 80, 300, 1140, 300, $text_color);
// Output of the image
header('Content-type: image/png');
imagepng($img);
imagedestroy($img);
?> आउटपुट

उदाहरण 2
<?php
// Create an image using imagecreate() function
$img = imagecreate(700, 300);
// Allocate the colors
$grey = imagecolorallocate($img, 122, 122, 122);
$blue = imagecolorallocate($img, 0, 0, 255);
// Set the thickness of the line
imagesetthickness($img, 15);
// Add a grey background color
imageline($img, 0, 0, 550, 400, $grey);
// Add a blue line
imageline($img, 0, 0, 550, 400, $blue);
// Output the image
header('Content-type: image/png');
imagepng($img);
imagedestroy($img);
?> आउटपुट
