Exif thumbnail

This snippet shows how to extract the EXIF thumbnail of a picture.

// file to read
$file = 'test.jpg';
$image = exif_thumbnail($file, $width, $height, $type);
// width, height and type get filled with data
// after calling "exif_thumbnail"
if ($image) {
    // send header and image data to the browser:
    header('Content-type: ' .image_type_to_mime_type($type));
    print $image;
else {
    // there is no thumbnail available, handle the error:
    print 'No thumbnail available';
Snippet Details

Sorry folks, comments have been deactivated for now due to the large amount of spam.

Please try to post your questions or problems on a related programming board, a suitable mailing list, a programming chat-room,
or use a QA website like stackoverflow because I'm usually too busy to answer any mails related
to my code snippets. Therefore please just mail me if you found a serious bug... Thank you!

Older comments:

RITH June 18, 2011 at 02:51
This function It don't work on my page.
It shows the message : Fatal error: Call to undefined function exif_thumbnail() in C:wampwwwMy Personal WebsiteAdminPicture.php on line 343
I don't know how to do it.
Amit khare September 10, 2010 at 17:41
Fatal error: Call to undefined function exif_thumbnail() in C:wampwwwweb1exifthumb.php on line 5