Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

exif_imagetype

Description

The exif_imagetype of Exif for PHP determines the type of an image.

Syntax

exif_imagetype(
    string $filename
): int|false

Parameters

filename

The image being checked.

Return

Returns the appropriate constant value, otherwise it returns false.

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

NOTE: exif_imagetype() will emit an E_NOTICE and return false if it is unable to read enough bytes from the file to determine the image type.

Examples

1 · filename

<?

$filename = $_SERVER["DOCUMENT_ROOT"] . "/assets/jpg/1.jpg";

$return = exif_imagetype($filename);

echo $return;

?>
2

2 · image_type_to_extension

<?

$filename = $_SERVER["DOCUMENT_ROOT"] . "/assets/jpg/1.jpg";

$return = exif_imagetype($filename);

echo image_type_to_extension($return);

?>
.jpeg

3 · image_type_to_mime_type

<?

$filename = $_SERVER["DOCUMENT_ROOT"] . "/assets/jpg/1.jpg";

$return = exif_imagetype($filename);

echo image_type_to_mime_type($return);

?>
image/jpeg
HomeMenu