Skip to content
geeksforgeeks
  • 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
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • 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 composite() Function
Next article icon

PHP | ImagickDraw comment() Function

Last Updated : 23 Dec, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report
The ImagickDraw::comment() function is an inbuilt function in PHP which is used to add a comment to a vector output stream. The comment is appended at the end of the output stream. Syntax:
bool ImagickDraw::comment( string $comment )
Parameters: This function accept a single parameter $comment which holds the comment. Return Value: This function returns TRUE on success. Exceptions: This function throws ImagickException on error. Below given program illustrates the ImagickDraw::comment() function in PHP: Program 1:
<?php
  
//Create a new Imagick object
$imagick = new Imagick();
  
// Create a image on imagick object
$imagick->newImage(800, 250, 'white');
  
// Create a new ImagickDraw object
$draw = new ImagickDraw();
  
// Add comment
$draw->comment('Hello ! This is my comment.');
  
// Get the vector graphics as string
$graphics = $draw->getVectorGraphics();
  
// Get comment from vector graphics
$comment = substr($graphics, 807); 
echo $comment;
?>
                      
                       
Output:
Hello ! This is my comment.
Program 2:
<?php
  
//Create a new Imagick object
$imagick = new Imagick();
  
// Create a image on imagick object
$imagick->newImage(800, 250, 'white');
  
// Create a new ImagickDraw object
$draw = new ImagickDraw();
  
$string = 'This is my comment';
  
// Add comment
$draw->comment($string);
  
// Get the vector graphics
$graphics = $draw->getVectorGraphics();
  
// Get comment from vector graphics
$getComment = substr($graphics, 807, strlen($string));
  
// Set the font size
$draw->setFontSize(50);
  
// Write on image
$draw->annotation(50, 100, $getComment);
  
// Render the draw commands
$imagick->drawImage($draw);
  
// Show the output
$imagick->setImageFormat('png');
header("Content-Type: image/png");
echo $imagick->getImageBlob();
?>
                      
                       
Output: Reference: https://www.php.net/manual/en/imagickdraw.comment.php


Next Article
PHP | ImagickDraw composite() Function
author
gurrrung
Improve
Article Tags :
  • PHP
  • Web Technologies
  • PHP-function
  • PHP-Imagick

Similar Reads

  • PHP | ImagickDraw clone() Function
    The ImagickDraw::clone() function is an inbuilt function in PHP which is used to make an exact copy of the specified ImagickDraw object. Syntax: ImagickDraw ImagickDraw::clone( void ) Parameters: This function doesn’t accepts any parameter. Return Value: This function returns the exact copy of the s
    2 min read
  • PHP | ImagickDraw __construct() Function
    The ImagickDraw::__construct() function is an inbuilt function in PHP which is used to initialize a ImagickDraw object. Syntax: bool ImagickDraw::__construct( void ) Parameters: This function doesn’t accept any parameter. Return Value: This function returns TRUE on success. Exceptions: This function
    1 min read
  • PHP | ImagickDraw composite() Function
    The ImagickDraw::compose() function is an inbuilt function in PHP which is used to composite an image into the current image, using the specified composition operator, specified position, and at the specified size. Syntax: bool ImagickDraw::compose( int $compose, float $x, float $y, float $width, fl
    2 min read
  • PHP | ImagickDraw clear() Function
    The ImagickDraw::clear() function is an inbuilt function in PHP which is used to clear the ImagickDraw object of any accumulated commands, and resets the settings it contains to their defaults. Syntax: bool ImagickDraw::clear( void ) Parameters: This function doesn’t accepts any parameter. Return Va
    2 min read
  • PHP | ImagickDraw color() Function
    The ImagickDraw::color() function is an inbuilt function in PHP which is used to draw color on the image using the current fill color, starting at the specified position, and using specified paint method. Syntax: bool ImagickDraw::color( float $x, float $y, int $paintMethod ) Parameters: This functi
    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
  • PHP | Imagick commentImage() Function
    The Imagick::commentImage() function is an inbuilt function in PHP which is used to add the comment in an image. Syntax: bool Imagick::commentImage( $comment ) Parameters: This function accepts a single parameter $comment which is used to hold the comment. Return Value: This function returns True on
    1 min read
  • PHP | ImagickDraw circle() Function
    The ImagickDraw::circle() function is an inbuilt function in Imagick library of PHP which is used to draw a circle. Syntax: bool ImagickDraw::circle( $ox, $oy, $px, $py ) Parameters: This function accepts four parameters as mentioned above and described below: $ox: This parameter takes the value of
    1 min read
  • PHP | ImagickDraw destroy() Function
    The ImagickDraw::destroy() function is an inbuilt function in PHP which is used to free all resources associated with the ImagickDraw object. Syntax: bool ImagickDraw::destroy( void ) Parameters: This function doesn’t accepts any parameter. Return Value: This function returns TRUE on success. Except
    1 min read
  • PHP | Gmagick commentImage() Function
    The Gmagick::commentImage() function is an inbuilt function in PHP which is used to add the comment in an image. Syntax: Gmagick Gmagick::commentImage( $comment ) Parameters: This function accepts a single parameter $comment which is used to hold the comment. Return Value: This function returns the
    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