PHP Imagick setImageFilename () Function

PHP

Syntax:
bool Imagick::setImageFilename (string $filename)
Parameters:This function takes one parameter, $filename,which contains a string representing the file name.Return value:this the function returns TRUE on success.Exceptions:this function throws an ImagickException on error.The following programs illustrate the Imagick::setImageFilename() functionin PHP:Program 1:  
// Create a new imagick object $imagick = new Imagick (' https://media.engineerforengineer .org / wp-content / uploads / engineerforengineer-13.png ' );  
// Set file name $imagick -> setImageFilename ( 'myNewFilename.png' );  
// Get file name $name = $imagick -> getImageFilename(); echo $name ; ?>
Output:
myNewFilename.png
Program 2:
 
// Create a new imagick object $imagick = new Imagick ( ' https://media.engineerforengineer.org/wp-content/uploads/engineerforengineer-13.png ' );  
// Set file name $imagick -> setImageFilename ( 'myAnotherNewFilename.png' );  
// Get file name $name = $imagick -> getImageFileName();  
// Save the image to the same folder $imagick -> writeImage ( $name ); ?>
Output:
This program creates a file called myAnotherNewFilename.png in the same folder.
Link: https://www.php.net/ manual / en / imagick.setimagefilename.php



Get Solution for free from DataCamp guru