Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • PHP Tutorial
  • PHP Exercises
  • PHP Array
  • PHP String
  • PHP Calendar
  • PHP Filesystem
  • PHP Math
  • PHP Programs
  • PHP Array Programs
  • PHP String Programs
  • PHP Interview Questions
  • PHP GMP
  • PHP IntlChar
  • PHP Image Processing
  • PHP DsSet
  • PHP DsMap
  • PHP Formatter
  • Web Technology
Open In App
Next Article:
PHP | ImagickDraw line() Function
Next article icon

PHP | ImagickDraw line() Function

Last Updated : 10 Oct, 2021
Comments
Improve
Suggest changes
Like Article
Like
Report

The ImagickDraw::line() function is an inbuilt function in Imagick library of PHP which is used to draw a line. This function draw the line using the current stroke color, stroke opacity, and stroke width.
 

Syntax:  

bool ImagickDraw::line( $sx, $sy, $ex, $ey )


Parameters: This function accepts four parameters as mentioned above and described below:  

  • $sx: This parameter takes the value of starting x coordinate.
  • $sy: This parameter takes the value of starting y coordinate.
  • $ex: This parameter takes the value of ending x coordinate.
  • $ey: This parameter takes the value of ending y coordinate.


Return Value: This function returns TRUE on success.
Below program illustrate the ImagickDraw::line() function in PHP:
Program:  

php
<?php  // Create an Imagick object $draw = new \ImagickDraw();  // Function to fill color $draw->setFillColor('red');  // Function to draw line $draw->line(10, 30, 180, 200);  // Create Imagick object $imagick = new \Imagick();  // Create new image of given size $imagick->newImage(300, 300, 'white');  // Set the image format $imagick->setImageFormat("png");  // Function to draw the image $imagick->drawImage($draw);  header("Content-Type: image/png");  // Display the output image     echo $imagick->getImageBlob(); ?> 

Output: 


Reference: http://php.net/manual/en/imagickdraw.line.php 


Next Article
PHP | ImagickDraw line() Function

S

sarthak_ishu11
Improve
Article Tags :
  • Misc
  • Technical Scripter
  • Web Technologies
  • PHP
  • Image-Processing
  • PHP-function
  • PHP-Imagick
Practice Tags :
  • Misc

Similar Reads

    PHP | GmagickDraw line() Function
    The GmagickDraw::line() function is an inbuilt function in PHP which is used to draw a line. This function draw the line using the current stroke color, stroke opacity, and stroke width. Syntax: public GmagickDraw::line( $sx, $sy, $ex, $ey )   Parameters:This function accepts four parameters as ment
    2 min read
    PHP | ImagickDraw pathClose() Function
    The ImagickDraw::pathClose() function is an inbuilt function in PHP which is used to add a path element to the current path which closes the current subpath by drawing a straight line. In simple words, it is used to completely apply a stroke to all the edges. Syntax: bool ImagickDraw::pathClose( voi
    2 min read
    PHP | ImagickDraw pathFinish() Function
    The ImagickDraw::pathFinish() function is an inbuilt function in PHP which is used to terminate the current path. This is required when multiple paths are to be drawn in the image. Syntax: bool ImagickDraw::pathFinish( void ) Parameters: This function doesn’t accepts any parameter. Return Value: Thi
    2 min read
    PHP | ImagickDraw pop() Function
    The ImagickDraw::pop() function is an inbuilt function in PHP which is used to destroy the current ImagickDraw in the stack and returns the previously pushed ImagickDraw. For every pop() function there must have already been an equivalent push() function. Syntax: bool ImagickDraw::pop( void ) Parame
    2 min read
    PHP | ImagickDraw arc() Function
    The ImagickDraw::arc() function is an inbuilt function in Imagick library of PHP which is used to draw an arc. Syntax: bool ImagickDraw::arc( $sx, $sy, $ex, $ey, $sd, $ed ) Parameters: This function accepts six parameters as mentioned above and described below: $sx: This parameter takes the value of
    1 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences