Speed up development with full-stack environments for every branch.

Learn More

Get the type of an image with exif_imagetype()

82 Runs 1249 Views 184 Copies
Saved

Saved

gtsolutions 373

gtsolutions
published 4 years ago

<?php

/**
 * PHP exif() module
 * get the type of an image with exif_imagetype()
 * 
 */
//setting the style for the display div
$divStyle = ' background-color:#E8E8E3;
            padding:10px;
            color:#000;
            font-size:16px;
            width:30%;';

$imageTypes = array(
    1 => 'GIF',
    2 => 'JPEG',
    3 => 'PNG',
    4 => 'SWF',
    5 => 'PSD',
    6 => 'BMP',
    7 => 'TIFF_II',
    8 => 'TIFF_MM',
    9 => 'JPC',
    10 => 'JP2',
    11 => 'JPX',
    12 => 'JB2',
    13 => 'SWC',
    14 => 'IFF',
    15 => 'WBMP',
    16 => 'XBM',
    17 => 'ICO');

$imagesNames = array(
    'images/image1.png',
    'images/image2.jpg',
    'images/image3.gif'
);
echo '<center>';
foreach ($imagesNames as $image)
    echo '<div style = "' . $divStyle . '">
The image <img src = "' . $image . '"> is a : ' . $imageTypes[exif_imagetype($image)] . '
</div><br />';
echo '</center>';
?>
Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).