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 | Imagick clone() Function
Next article icon

PHP | ImagickDraw clone() Function

Last Updated : 20 Dec, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report

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 specified ImagickDraw object on success or error on failure.

Exceptions: This function throws ImagickException on error.

Below programs illustrate the ImagickDraw::clone() 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();
  
// Set the text properties
$draw->setFontSize(100);
$draw->setFillColor('blue');
  
// Apply the annotation() function
$draw->annotation(50, 150, 'GeeksforGeeks');
  
// Create a new ImagickDraw object
$copied = new ImagickDraw();
  
// Copy the object
$copied = $draw->clone();
  
//  Render the draw commands from copied object
$imagick->drawImage($copied);
  
// Show the output
$imagick->setImageFormat("png");
header("Content-Type: image/png");
  
echo $imagick->getImageBlob();
?>
 
 

Output:

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();
  
// Draw a circle
$draw->circle(200, 100, 100, 100);
  
// Create a new ImagickDraw object
$copied = new ImagickDraw();
  
// Copy the object
$copied = $draw->clone();
  
//  Render the draw commands from copied object
$imagick->drawImage($copied);
  
// Add a border
$imagick->borderImage('black', 1, 1);
  
// Show the output
$imagick->setImageFormat("png");
header("Content-Type: image/png");
  
echo $imagick->getImageBlob();
?>
 
 

Output:

Reference: https://www.php.net/manual/en/imagickdraw.clone.php



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

Similar Reads

  • PHP | Imagick clone() Function
    The Imagick::clone() function is an inbuilt function in PHP which is used to create a copy of Imagick object. This function creates copy of the same instance, that means it will have same properties and any change in it will not reflect to the main object. Syntax: Imagick Imagick::clone( void ) Para
    1 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 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 comment() Function
    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
    2 min read
  • PHP | ImagickDraw affine() Function
    The ImagickDraw::affine() function is an inbuilt function in PHP which is used to adjust the current affine transformation matrix. Syntax: bool ImagickDraw::affine( array $affine ) Parameters: This function accepts a single parameter $affine which holds the array containing the affine matrix paramet
    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 ellipse() Function
    The ImagickDraw::ellipse() function is an inbuilt function in PHP which is used to draw an ellipse on the image. Syntax: bool ImagickDraw::ellipse( float $ox, float $oy, float $rx, float $ry, float $start, float $end ) Parameters: This function accepts six parameters as mentioned above and described
    2 min read
  • PHP | Imagick clear() Function
    The Imagick::clear() function is an inbuilt function in PHP which is used to clear all resource allocated to an Imagick object. Syntax: bool Imagick::clear( void ) Parameters: This function does not accept any parameter. It just clears off the resources of the Imagick object which is used to call th
    2 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