Friday, October 10, 2025
HomeLanguagesPHP | exif_imagetype() function

PHP | exif_imagetype() function

The exif_imagetype() function is an inbuilt function in PHP which is used to determine the type of an image.
Syntax: 
 

int exif_imagetype( string $filename )

Parameters:This function accepts a single parameter $filename which holds the name or URL of the image.
Return Value: This function returns an integer corresponding to one of IMAGETYPE constants as given below: 
 

  • IMAGETYPE_GIF (1)
  • IMAGETYPE_JPEG (2)
  • IMAGETYPE_PNG (3)
  • IMAGETYPE_SWF (4)
  • IMAGETYPE_PSD (5)
  • IMAGETYPE_BMP (6)
  • IMAGETYPE_TIFF_II (7)
  • IMAGETYPE_TIFF_MM (8)
  • IMAGETYPE_JPC (9)
  • IMAGETYPE_JP2 (10)
  • IMAGETYPE_JPX (11)
  • IMAGETYPE_JB2 (12)
  • IMAGETYPE_SWC (13)
  • IMAGETYPE_IFF (14)
  • IMAGETYPE_WBMP (15)
  • IMAGETYPE_XBM (16)
  • IMAGETYPE_ICO (17)
  • IMAGETYPE_WEBP (18)

Below given programs illustrate the exif_imagetype() function in PHP: 
Program 1: In this example we will check the format of a image file. 
 

php




<?php
// Load an image from PNG URL
$type = exif_imagetype(
 
echo $type;
?>


Output: 
 

3 // which corresponds to IMAGETYPE_PNG

Program 2: In this example we will check if a image file is supported or not. 
 

php




<?php
// Load an image from JPEG URL
$type = exif_imagetype(
 
if($type > 0 || $type < 19)
{
    echo 'This is a supported image format.';
}
?>


Output: 
 

This is a supported image format.

Reference: https://www.php.net/manual/en/function.exif-imagetype.php
 

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32349 POSTS0 COMMENTS
Milvus
87 POSTS0 COMMENTS
Nango Kala
6717 POSTS0 COMMENTS
Nicole Veronica
11880 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11941 POSTS0 COMMENTS
Shaida Kate Naidoo
6838 POSTS0 COMMENTS
Ted Musemwa
7097 POSTS0 COMMENTS
Thapelo Manthata
6792 POSTS0 COMMENTS
Umr Jansen
6792 POSTS0 COMMENTS