Open In App

PHP | Gmagick getimagefilename() Function

Last Updated : 21 Jan, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report
The Gmagick::getimagefilename() function is an inbuilt function in PHP which is used to get the filename of a particular image in a sequence. Syntax:
string Gmagick::getimagefilename( void )
Parameters: This function doesn’t accept any parameter. Return Value: This function returns an string value containing the filename. Exceptions: This function throws GmagickException on error. Below given programs illustrate the Gmagick::getimagefilename() function in PHP: Program 1: php
<?php

// Create a new Gmagick object
// https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png
$gmagick = new Gmagick('geeksforgeeks.png');
 
// Get the filename
$name = $gmagick->getimagefilename();
echo $name;
?>
Output:
geeksforgeeks.png
Program 2: php
<?php

// Create a new Gmagick object
// https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png
$gmagick = new Gmagick('geeksforgeeks.png');

// Rename the image
$gmagick->setimagefilename('my_new_name.png');

// Get the filename
$name = $gmagick->getimagefilename();
echo $name;
?>
Output:
my_new_name.png
Reference: https://www.php.net/manual/en/gmagick.getimagefilename.php

Similar Reads