Open In App

PHP | Imagick setImage() Function

Last Updated : 15 Nov, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

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:




<?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;
?>


Output:

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


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads