Using exifer under mg2
vice the default exif reader
- This tutorial will not cover how to setup and configure mg2, that
topic is outside the scope of this document. In the following
examples, I have mg2 installed in /web/photos
so if your installation path is different, please take that into
account.
- I cannot be held responsible for any damage done to your machine, if
you follow closely, you should have little trouble integrating exifer
into mg2.
- The purpose of this document is to demonstrate how to configure mg2
to use exifer[1]
vice the default installed exif
reader[2].
- The default installation of mg2 currently installs Exif reader v 1.2
which is actually a problem for us Canon users. Canon (and other
camera manufacturers) makes extensive use of something called the
MakerNote field of the EXIF header. Even for something like the
ISO setting, this information is stored in a different part of the EXIF
data section from most other digital cameras and requires special
decoding. Currently, the exif parser script packaged with mg2 is
unable to retrieve any of this valuable information. For a
breakdown of what kind of information can be obtained from the
MakerNote section please take a look at Description of EXIF file format
[3]
- Lets get started by download from the Exifer site
the required file, as of Feb 18, 2005 version 1.5 is available.
Unzip this file to a temporary directory.
Copy this new exif.php file to /web/photos/includes/myexif.php
Copy the canon.php file from
within the makers directory to /web/photos/includes/mycanon_exif.php
- In the main directory for mg2, make a backup copy of index.php and
edit it the original to make the following modifications: At
around line 272 is the statement include("includes/exif.php");
Edit that line to say include("includes/myexif.php");
Save and exit this file.
- Now we must edit photos/includes/myexif.php
and around line 593 is the statement require_once('makers/canon.php'); We
must change it to read require_once('myexif_canon.php'); If
you are following my conventions.
- Open up photos/index.php in
an editor and around line 270 is where the program starts dealing with
exif information. We need to change the file:
From This:
// DISPLAY EXIF
if ($mg2->showexif == "1"){
include("includes/exif.php");
exif($result[0][1]);
if
($exif_data['Model'] != "") {
$exif_data['ExposureTime'] =
$mg2->dec2frac(round($exif_data['ExposureTime'],2)) .
$mg2->lang['seconds'];
$exif_data['ExposureBias'] = round($exif_data['ExposureBias'],2);
$exif_data['FNumber'] = "f" . $exif_data['FNumber'];
$exif_data['FocalLength'] = $exif_data['FocalLength'] .
$mg2->lang['mm'];
include("skins/$mg2->activeskin/templates/viewimage_exif.php");
}
}
To This:
// DISPLAY EXIF
if ($mg2->showexif ==
"1"){
include("includes/myexif.php");
$exif =
read_exif_data_raw($result[0][1],"no");
if
($exif['IFD0']['Model'] != "") {
include("skins/$mg2->activeskin/templates/viewimage_exif.php");
}
}
- Next we have to configure our skin to output the exif information we
are actually interested in. By looking through the myexif_canon.php file, we can see
all of the fields that are available to us. When we have an idea
what we want, we can edit our photos/skins/skin_name/templates/viewimage_exif.php
These
Settings:
<br />
<br />
<table cellspacing="5"
cellpadding="0" class="table_exif" width="300" align="center">
<tr>
<td
colspan="2" align="center"><b><? echo $mg2->lang['exif
info'] ?></b></td>
</tr>
<tr>
<td><? echo $mg2->lang['model'] ?></td>
<td><? echo trim($exif['IFD0']['Model']) ?></td>
</tr>
<tr>
<td>Shutter Speed</td>
<td><? echo $exif['SubIFD']['ExposureTime'] ?></td>
</tr>
<tr>
<td><? echo $mg2->lang['aperture'] ?></td>
<td><? echo $exif['SubIFD']['FNumber'] ?></td>
</tr>
<tr>
<td>ISO</td>
<td><? echo $exif['SubIFD']['MakerNote']['Settings 1']['ISO']
?></td>
</tr>
<tr>
<td>Exposure Mode</td>
<td><? echo $exif['SubIFD']['MakerNote']['Settings
1']['ExposureMode'] ?></td>
</tr>
<tr>
<td>Shooting Mode</td>
<td><? echo $exif['SubIFD']['MakerNote']['Settings
1']['EasyShooting'] ?></td>
</tr>
<tr>
<td>White Balance</td>
<td><? echo $exif['SubIFD']['MakerNote']['Settings
4']['WhiteBalance'] ?></td>
</tr>
<tr>
<td>Metering Mode</td>
<td><? echo $exif['SubIFD']['MakerNote']['Settings
1']['MeteringMode'] ?></td>
</tr>
<tr>
<td>Flash Mode</td>
<td><? echo $exif['SubIFD']['MakerNote']['Settings
1']['FlashActivity'] ?></td>
</tr>
<tr>
<td>Subject Distance</td>
<?
$subjdis = $exif['SubIFD']['MakerNote']['Settings
4']['SubjectDistance'];
$subjdis = $subjdis * 0.01;
?>
<td><? echo "$subjdis"."m" ?></td>
</tr>
<tr>
<td>Focal Length</td>
<?
$flen = $exif['SubIFD']['FocalLength']
?>
<!--
<td><? echo "$flen"."m" ?></td> -->
<td>
<?
printf("%.2f", $flen);
echo "mm";
?>
</td>
</tr>
<tr>
<td>Lens</td>
<td><? echo "5.4-16.2mm" ?></td>
</tr>
<tr>
<td>Original Taken</td>
<td><? echo trim($exif['SubIFD']['DateTimeOriginal'])
?></td>
</tr>
</table>
Will
Produce Something Like This:
|
Exif
Information
|
|
Model
|
Canon
PowerShot A70
|
|
Shutter
Speed
|
1/320 sec
|
|
Aperture
|
f 5
|
|
ISO
|
100
|
|
Exposure
Mode
|
Manual
|
|
Shooting
Mode
|
Manual
|
|
White
Balance
|
Sunny
|
|
Metering
Mode
|
Evaluative
|
|
Flash Mode
|
Flash Did
Not Fire
|
|
Subject
Distance
|
0.12m
|
|
Focal Length
|
5.41mm
|
|
Lens
|
5.4-16.2mm
|
|
Original
Taken
|
2004:07:27
14:47:02
|
- Pretty nice eh? Of course, the possibilities are endless and
they
don't have to be just outputed in table format like above, it can be a
more
free form display if you wish.
- Happy exifering...
|
|