Author Topic: [Mod] photography date  (Read 3579 times)

0 Members and 1 Guest are viewing this topic.

Offline pht3k

  • Pre-Newbie
  • Posts: 8
    • View Profile
[Mod] photography date
« on: April 15, 2006, 09:41:57 PM »
Hi all,

This is my first mod so be comprehensive if i do something wrong.

My girlfriend had complaints about the date showed under the description of the picture.  She wanted to know the date the picture was photographied instead of the date it was added to the database.  I corrected the situation.  So here's how to achieve this :

1. Install [Mod] EXIF 0.3

Of course you need to have an exif enabled digital camera.

2. Add DateTimeOriginal to the 'EXIF_FILTER' section of the exif.php file

Code: [Select]
define('EXIF_FILTER', "
Model:
DateTimeOriginal:
Orientation:
ExposureTime:
FNumber:
ISOSpeedRatings:
ExposureBiasValue:
MeteringMode:
Flash:
FocalLength:
ColorSpace:
");
 

3. Get date from exif and modify the format so it is the same as the image_date, then add the date to pic_date tag.  To do so, add some code to the section 3 from the exif mod, so it now looks like this :

Code: [Select]
     $exif_info = "";
     if ($image_info[2] == 2 && $detailed_view && !is_remote($media_file_name)) {
       $exif = exif_read_data ($media_src,'IFD0');
       $bgcounter = 0;
       if ($exif) {
         $exif = exif_read_data ($media_src,0,true);       
         foreach($exif as $key=>$section) {
           if (($key == "IFD0") || ($key == "EXIF")) {
             foreach($section as $name=>$val) {
              if (!(exif_filter($name)) && exif_filter_control()) continue;
               $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
               $site_template->register_vars(array(
                 "exif_value" => exif_parse_value($name, $val),
                 "exif_name" => $name . ":",
                 "row_bg_number" => $row_bg_number
               ));
               $exif_info .= $site_template->parse_template("exif_bit");
                if ($name=="DateTimeOriginal")
                      {
                      $val2=explode(" ", $val);
                      $heure=$val2[1];
                      $heure=explode(":", $heure);
                      $heure=$heure[0].":".$heure[1];
                      $datt=$val2[0];
                      $datt=explode(":", $datt);
                      $datt=$datt[2].".".$datt[1].".".$datt[0];
                      $pic_date=$datt." ".$heure;
                      }
                $site_template->register_vars(array(
                "pic_date" => $pic_date
             }
           }
         }
       }
     }

4. Use the new {pic_date} tag in the templates.  Here you are free to adjust the layout to fit your needs.  Personnally, I kept both the image_date and pic_date tags but you can keep only the new pic_date if you want.  As an exemple, here's a section from my details.html file :

Code: [Select]
                        <tr>
                          <td width=300 valign="top" class="row1"><b>{lang_description}</b></td>
                          <td valign="top" class="row1">{image_description}</td>
                        </tr>
                        <tr>
                          <td width=300 valign="top" class="row2"><b>picture date:</b></td>
                          <td valign="top" class="row2">{pic_date}</td>
                        </tr>
                        <tr>
                          <td width=300 valign="top" class="row1"><b>addition date:</b></td>
                          <td valign="top" class="row1">{image_date}</td>
                        </tr>
                        <tr>
                          <td width=300 valign="top" class="row2"><b>{lang_hits}</b></td>
                          <td valign="top" class="row2">{image_hits}</td>
                        </tr>

5. Optionnal.  I haven't tried this but i suppose you dont have to display the exif info if you dont want to.  So you can omit the sections 4,5 and 6 from the exif mod.  If you do this, you should also change the 'EXIF_FILTER' section of the exif.php file to remove unused info to spare some processing and maybe improve access time to your webpage :

Code: [Select]
define('EXIF_FILTER', "
DateTimeOriginal:
");


I hope you enjoy it :)

pht3k
« Last Edit: April 18, 2006, 05:05:44 AM by pht3k »

Offline pht3k

  • Pre-Newbie
  • Posts: 8
    • View Profile
Re: [Mod] photography date
« Reply #1 on: April 18, 2006, 04:24:44 AM »
Hi,

I did some testing with adobe elements and realized it is changing the DateTime exif info.  So, in case DateTime is not reflecting the real photography date, try DateTimeOriginal instead.  DateTimeOriginal is working flawlessly for me.

cya,
pht3k

UPDATE : don't take care of this message ; i updated it directly in the main post so everyone use DateTimeOriginal instead of DateTime as there is no reason to use DateTime if the goal is to have the date the photography was taken.
« Last Edit: April 18, 2006, 05:08:32 AM by pht3k »