exif_imagetype

exif_imagetype

When an image is uploaded through a form, its size, type, etc are provided for us as part of the $_FILE associative array, but how do you check the type of an image on the local machine or across a network? The exif_imagetype function is the answer.

This function determines the header type of an image file. There are numerous constants such as IMAGETYPE_GIF, IMAGETYPE_BMP, etc that can be used to determine the type of the image. It’s function looks like this:

int|false exif_imagetype ( string filename)

The exif_imagetype function is part of the GD image library, so you must have this library installed for the exif_imagetype function to work. Here’s some code to check whether the function exists and then to output the type of a GIF image file:

<?php

if(function_exists(”exif_imagetype”))
echo exif_imagetype(”/pics/bounty.gif”);
else
echo “You don’t have the GD image library installed”;

?>

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.