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

उदाहरण 2
<?php
// imagecreate() फ़ंक्शन का उपयोग करके इमेज बनाएं
$img = imagecreate(700, 300);
// रंग आवंटित करें
$grey = imagecolorallocate($img, 122, 122, 122);
$blue = imagecolorallocate($img, 0, 0, 255);
// लाइन की मोटाई सेट करें
imagesetthickness($img, 15);
// ग्रे बैकग्राउंड कलर जोड़ें
imageline($img, 0, 0, 550, 400, $grey);
// नीली लाइन जोड़ें
imageline($img, 0, 0, 550, 400, $blue);
// इमेज आउटपुट करें
header('Content-type: image/png');
imagepng($img);
imagedestroy($img);
?>
आउटपुट
