// create image resource $image = imagecreatefromjpeg("image.jpg"); // get the filename of the image $file = image_file(filename); // display the filename echo "Filename: ".$file;
// create image resource $image = imagecreatefrompng("image.png"); // get the filename of the image $file = image_file(filename); // print the filename print_r($file);This example is similar to the previous one, but we create an image resource from a png file this time. We then use the getFile() function to get the filename of the image and print it. These examples are part of the PHP GD library, a graphics library that is focused on creating and manipulating images. The GD library is included with many PHP installations and can be installed as an extension on those that do not have it.