Approaches to Web Development for Bioinformatics

Previous  Contents  Next
References

Image Metadata

PHP scripts can be used to find image metadata information. To do this PHP must be configured to load the EXIF libary. The PHP manual 35 gives details on the use of the use of the EXIF library.

Here is a program that finds metadata from an image file and prints it out by dumping the array contents.


PHP

<?php
$exif = exif_read_data('../images/230px-Heart-and-lungs.jpg');
print_r($exif);
?>

The program read the image data with the function exif_read_data($fileName). The program output is


Program Output

Array (
[FileName] => 230px-Heart-and-lungs.jpg
[FileDateTime] => 1160236437
[FileSize] => 16304
[FileType] => 2
[MimeType] => image/jpeg
[SectionsFound] => [COMPUTED] => Array (
[html] => width="230" height="224" [Height] => 224 [Width] => 230 [IsColor] => 1
)
)

The EXIF library also has a function exif_thumbnail() to extract an embedded thumbnail image from a JPG or TIFF file. this is demonstrated by the following program.


PHP

<?php
$thumbnail = exif_thumbnail('../images/redbloodcells.jpg', $width, $height, $type);
if ($thumbnail != false) {
$mime = image_type_to_mime_type($type);
header("Content-type: $mime");
print($thumbnail);
} else {
print("No thumbnail available.");
}
?>

The program output is shown below.

EXIF Extracted Thumbnail
EXIF Extracted Thumbnail

Previous  Contents  Next
References

Contributed Comments and NotesAdd a comment.

There are no user comments.

Google

Please send ideas and opinions by email at alexamies@gmail.com.

© 2006-2007 Alex Amies