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

PHP | ImagickDraw composite() Function

Last Updated : 07 Mar, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

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, float $height, Imagick $compositeWand )

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

  • $compose: It specifies the composition operator which corresponds one of COMPOSITE constants.
  • $x: It specifies y-coordinate of the top left corner.
  • $y: It specifies x-coordinate of the top left corner.
  • $width: It specifies width of the composition image.
  • $height: It specifies height of the composition image.
  • $compositeWand: It specifies the Imagick object where composition image is taken from.

Return Value: This function returns TRUE on success. Below programs illustrate the ImagickDraw::compose() function in PHP: Program 1: 

php

<?php
  
// Create a new imagick object
$imagick = new Imagick(
'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png');
  
// Create a new ImagickDraw object
$draw = new ImagickDraw();
  
// Composite the Image
$draw->composite(imagick::COMPOSITE_COLORIZE,
                   100, 100, 200, 200, $imagick);
  
// Create a new Imagick object
$imagick2 = new Imagick();
  
// Create a image on imagick object
$imagick2->newImage(800, 250, 'white');
  
// Render the draw commands
$imagick2->drawImage($draw);
  
// Add border
$imagick->borderImage('green', 1, 1);
  
// Show the output
$imagick2->setImageFormat('png');
header("Content-Type: image/png");
echo $imagick2->getImageBlob();
?>
                      
                       

Output: Program 2: 

php

<?php
  
// Create a new imagick object
$imagick = new Imagick(
'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png');
  
// Create a new ImagickDraw object
$draw = new ImagickDraw();
  
// Composite the Image
$draw->composite(4, 200, 20, 400, 200, $imagick);
  
// Create a new Imagick object
$imagick2 = new Imagick();
  
// Create a image on imagick object
$imagick2->newImage(800, 250, 'orange');
  
// Render the draw commands
$imagick2->drawImage($draw);
  
// Show the output
$imagick2->setImageFormat('png');
header("Content-Type: image/png");
echo $imagick2->getImageBlob();
?>
                      
                       

Output:



Next Article
PHP | ImagickDraw circle() 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 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 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 | Imagick compositeImage() Function
    The Imagick::compositeImage() function is an inbuilt function in PHP which is used to composite one image into another image and gives composite image. Syntax: bool Imagick::compositeImage( $composite_object, $composite, $x, $y, $channel = Imagick::CHANNEL_DEFAULT ) Parameters: This function accepts
    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 __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 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 | Gmagick compositeimage() Function
    The Gmagick::compositeimage() function is an inbuilt function in PHP which is used to composite one image onto another at the specified offset. Offset is actually the distance from where to start compositing the second image. Syntax: Gmagick Gmagick::compositeimage( Gmagick $source, int $COMPOSE, in
    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 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