PHP | Imagick setImage() Function

The Imagick::setImage() function is an inbuilt function in PHP which is used to replace an image in the object.

Syntax:

bool Imagick::setImage( Imagick $replace )

Parameters: This function accepts single parameter $replace which holds an Imagick object.

Return Value: This function returns TRUE on success.

Exceptions: This function throws ImagickException on error.



Below program illustrates the Imagick::setImage() function in PHP:

Program:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Create two Imagick objects
$imagick_source = new Imagick(
  
$imagick_replace= new Imagick(
  
// Replacing geeksforgeeks24.png with colorize1.png
$imagick_source->setImage($imagick_replace);
  
// Display the output image
header('Content-type: image/jpeg');
  
echo $imagick_source;
?>

chevron_right


Output:

Reference: https://www.php.net/manual/en/imagick.setimage.php

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.