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

PHP | Imagick compositeImage() Function

Last Updated : 08 Aug, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report
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 five parameters as mentioned above and described below:
  • $composite_object: It is an Imagick object which holds the composite image or may be realpath of image to compose.
  • $composite: It is a Composite Operator Constants such as Imagick::COMPOSITE_DEFAULT, Imagick::COMPOSITE_MATHEMATICS, etc...
  • x: It holds the column offset of the composited image. The x value will be the numeric format.
  • y: It is hold the row offset of the composited image. The y value will be the numeric format.
  • $channel: It has Imagick channel constants which provides any channel constant that is valid for your channel mode. To apply more than one channel, combine channel type constants using bitwise operators.
    Return Value: It returns Boolean value True on success and false on failure. Below program illustrates the Imagick::compositeImage() function in PHP: Program: php
    <?php  // Declare Imagick objects $image1 = new \Imagick( "https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-9.png");   $image2 = new \Imagick( "https://media.geeksforgeeks.org/wp-content/uploads/negateImage.png");   // Resize the images $image1->resizeimage($image2->getImageWidth(),          $image2->getImageHeight(), \Imagick::FILTER_LANCZOS, 1);   // Create new Imagick object $new_image = new \Imagick();      // Create new image using ImageMagick pseudo-formats $new_image->newPseudoImage($image1->getImageHeight(),          $image1->getImageWidth(), "gradient:gray(10%)-gray(90%)");  // Rotate the image $new_image->rotateimage('black', 90);   // Use composite function to combined the image $image2->compositeImage($new_image, \Imagick::COMPOSITE_COPYOPACITY, 0, 0);  // Use composite function to combined the image $image1->compositeImage($image2, \Imagick::COMPOSITE_ATOP, 0, 0);   header("Content-Type: image/jpg");  // Display the output echo $image1->getImageBlob();  ?> 
    Output: Reference: https://www.php.net/manual/en/imagick.compositeimage.php

    Next Article
    PHP | Imagick chopImage() Function

    V

    VigneshKannan3
    Improve
    Article Tags :
    • Web Technologies
    • PHP
    • PHP-function
    • PHP-Imagick

    Similar Reads

    • 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 | Imagick colorizeImage() Function
      The Imagick::colorizeImage() function is an inbuilt function in PHP which is used to blends the fill color with each pixel in the image with a specified opacity. Syntax: bool Imagick::colorizeImage( mixed $colorize, mixed $opacity, bool $legacy = FALSE ) Parameters: This function accepts three param
      2 min read
    • PHP | Imagick chopImage() Function
      The Imagick::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: bool Imagick::chopImage( $width, $height, $x, $y )
      1 min read
    • PHP | Imagick cropImage() Function
      The Imagick::cropImage() function is an inbuilt function in PHP which is used to extracts the region of the image.Syntax:   int Imagick::cropImage( $width, $height, $x, $y ) Parameters: This function accept four parameters as mention above and describe below.   $width: This parameter is used to spec
      2 min read
    • PHP | Imagick clampImage() Function
      The Imagick::clampImage() function is an inbuilt function in PHP which is used to restricts the color range from 0 to the quantum depth. This function has no impact on the image which is already in given range. Syntax: bool Imagick::clampImage( int $channel = Imagick::CHANNEL_DEFAULT ) Parameters: T
      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 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 | Imagick convolveImage() Function
      The Imagick::convolveImage() function is an inbuilt function in PHP which is used to apply a custom convolution kernel to the image. Syntax: bool Imagick::convolveImage( $kernel, $channel ) Parameter: This function accepts two parameters as mentioned above and described below: $kernel: This paramete
      1 min read
    • PHP | Imagick contrastImage() Function
      The Imagick::contrastImage() function is an inbuilt function in PHP which is used to change the contrast of the image. This function enhances the intensity differences between the lighter and darker elements of the image. Syntax: bool Imagick::contrastImage(bool $sharpen) Parameters: This function a
      1 min read
    • PHP | Imagick embossImage() Function
      The Imagick::embossImage() function is an inbuilt function in PHP which is used to return a grayscale image with a three-dimensional effect. This function convolves the image with a Gaussian operator of the given radius and standard deviation. Syntax: bool Imagick::embossImage( $radius, $sigma ) Par
      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