Most digital cameras add EXIF (Exchangeable image file format) data to photos captured nowadays, embedding information like camera type, settings, timestamps, etc. into the captured file itself, and in the process creating a host of quite important (to enthusiasts anyway) bits of meta information in the process.
Extracting this information out of photos for display on a website turns out to be particularly easy, thanks to the powerful little exif_read_data function found in PHP.
(Just a note, for the exif family of PHP functions to work, you do need exif enabled in your installation. This can be verified by a quick look through your phpinfo file).
So let’s have an active example then:
if (file_exists($filepath)) {
echo '
- ';
$exif = exif_read_data($filepath, 0, true);
foreach ($exif as $key => $section) {
foreach ($section as $name => $val) {
echo "
- $key.$name: $val "; } } echo '
As you can see, this is probably the simplest way of extracting EXIF data out of a photo with PHP and there really is nothing to it other than a call to the exif_read_data function and keeping most of its accepted parameters at the defaults.
Nifty.
Related Link: http://php.net/exif_read_data