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

PHP | Gmagick clear() Function

Last Updated : 28 Aug, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report

The Gmagick::clear() function is an inbuilt function in PHP which is used to clear all resources associated to Gmagick object.

Syntax:

Gmagick Gmagick::clear( void )

 
Parameters: This function does not accepts any parameter.

Return Value: This function returns the cleared Gmagick object.

Errors/Exceptions: This function throws GmagickException on error.

Below programs illustrate the Gmagick::clear() function in PHP:

Program 1:




<?php 
     
// Create a GmagickDraw object 
$draw = new GmagickDraw(); 
    
// Create GmagickPixel object 
$fillColor = new GmagickPixel('Green'); 
    
// Set stroke opacity
$draw->setfillcolor('red');
  
// Set the width and height of image 
$draw->setStrokeWidth(7); 
$draw->setFontSize(72); 
     
// Function to draw circle  
$draw->circle(250, 250, 100, 150); 
   
$gmagick = new Gmagick(); 
$gmagick->newImage(500, 500, 'White'); 
$gmagick->setImageFormat("png"); 
$gmagick->drawImage($draw); 
  
// Using clear() function
print_r($gmagick->clear());
?> 
 
 

Output:

1

Program 2:




<?php 
      
// Create a GmagickDraw object 
$draw = new ImagickDraw();  
     
// Set the color
$draw->setFillColor('Green'); 
     
// Set the width and height of image 
$draw->setStrokeWidth(17); 
   
// Function to draw line
for($x = 0; $x < 40; $x++) {
    $draw->line(rand(0, 100), rand(0, 60), rand(0, 500), rand(0, 500));
    $draw->line(rand(0, 100), rand(0, 60), rand(0, 500), rand(0, 500));
    $draw->line(rand(0, 100), rand(0, 60), rand(0, 500), rand(0, 500));
    $draw->line(rand(0, 100), rand(0, 60), rand(0, 500), rand(0, 500));
}
  
$gmagick = new Imagick(); 
$gmagick->newImage(500, 500, 'White'); 
$gmagick->setImageFormat("png"); 
   
// Set the color
$draw->setFillColor('Black'); 
   
// Set Font Size
$draw->setFontSize(20); 
   
// Use of drawimage function
$gmagick->drawImage($draw); 
  
$gmagick->annotateImage($draw, 5, 220, 0, 
     'Stroke Width using getstrokewidth() function :'
                        . $draw->getstrokewidth());
   
// Using clear() function
print_r($gmagick->clear());
?> 
 
 

Output:

1

Reference: http://php.net/manual/en/gmagick.clear.php



Next Article
PHP | Imagick clear() Function
author
sarthak_ishu11
Improve
Article Tags :
  • PHP
  • Web Technologies
  • Image-Processing
  • PHP-function
  • PHP-Gmagick

Similar Reads

  • 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
  • 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 | Gmagick destroy() Function
    The Gmagick::destroy() function is an inbuilt function in PHP which is used to destroy the Gmagick object and frees all resources associated with it. Syntax: bool Gmagick::destroy( void ) Parameters: This function doesn’t accept any parameter. Return Value: This function returns TRUE on success. Exc
    1 min read
  • PHP | Gmagick current() Function
    The Gmagick::current() function is an inbuilt function in PHP which is used to return the reference of the current Gmagick object. This function does not create any copy but returns the same instance of Gmagick. Syntax: Gmagick Gmagick::current( void ) Parameters: This function doesn’t accept any pa
    1 min read
  • PHP | GmagickDraw arc() Function
    The GmagickDraw::arc() function is an inbuilt function in PHP which is used to draw an arc falling within a specified bounding rectangle on the image. Syntax:   GmagickDraw GmagickDraw::arc( float $sx, float $sy, float $ex, float $ey, float $sd, float $ed )  Parameters: This function accept six para
    2 min read
  • PHP | Gmagick despeckleimage() Function
    The Gmagick::despeckleimage() function is an inbuilt function in PHP which is used to reduce the speckle noise in an image while preserving the edges of the original image. Syntax: Gmagick Gmagick::despeckleimage( void ) Parameters: This function doesn’t accept any parameter. Return Value: This func
    1 min read
  • PHP | Gmagick __construct() Function
    The Gmagick::__construct() function is an inbuilt function in PHP which is used to create a Gmagick object. Further Gmagick manipulations can be done with this newly created Gmagick object. Syntax: public Gmagick::__construct( string $filename ) Parameters: This function accepts a single parameter $
    1 min read
  • PHP | Gmagick chopimage() Function
    The Gmagick::chopimage() function is an inbuilt function in PHP which is used to remove the region of an image and trim it. This function accepts the dimension of image and chops the area and the dimension from where the image is to be trim.Syntax: Gmagick Gmagick::chopimage( $width, $height, $x, $y
    2 min read
  • PHP | Gmagick blurimage() Function
    The Gmagick::blurimage() function is an inbuilt function in PHP which is used to add blur filter to the image. Syntax: Gmagick Gmagick::blurimage( $radius, $sigma, $channel ) Parameters: This function accepts three parameters as mentioned above and described below: $radius: This parameter is used to
    2 min read
  • PHP | Gmagick flopimage() Function
    The Gmagick::flopimage() function is an inbuilt function in PHP which is used to create a flopped image. This function creates a mirror image along the y-axis. Syntax: Gmagick Gmagick::flopimage( void )   Parameters: This function does not accept any parameter. Return Value: This function returns fl
    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