Friday, November 21, 2025
HomeLanguagesPHP | Imagick setImage() Function

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:




<?php
  
// Create two Imagick objects
$imagick_source = new Imagick(
  
$imagick_replace= new Imagick(
  
// Replacing neveropen24.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

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32405 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6781 POSTS0 COMMENTS
Nicole Veronica
11928 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11997 POSTS0 COMMENTS
Shaida Kate Naidoo
6907 POSTS0 COMMENTS
Ted Musemwa
7166 POSTS0 COMMENTS
Thapelo Manthata
6862 POSTS0 COMMENTS
Umr Jansen
6847 POSTS0 COMMENTS