News:

CPG Release 1.6.29
During HTML5 upload, keep pseudo blank code 200 messages from triggering error condition
added Russian language
correct failure to use theme menu icons in album manager
minor vulnerabilities mitigation

Main Menu

Sort by EXIF date mod port

Started by crabboy, April 22, 2007, 05:16:22 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

crabboy

I just upgraded my coppermine from 1.3.x to 1.4.10 the other day and I was horrified to find out that I still can't sort by EXIF date.  I had used a fantastic mod many years ago to accomplish this and it was now gone.  I searched around quite a bit and there was no port of the Dannisk mod or similar, there seems to be only a script that can accomplish the same task.  Not wanting to deal with the script, I ported the 1.3 mod to 1.4.10.

This is a direct port of the Dannisk 'Sort by EXIF date or Upload Date per Album' mod.  Please read the features, caveats and instructions for this mod at the below link.

http://coppermine-gallery.com/forum/index.php?topic=9360.0


I will be using steps from his original post to save time and so all the steps will be below.  If you have previously modded 1.3 and upgraded to 1.4, as I did, you may skip Step 1. 


Step 1: Modifying the database

Change {$CONFIG['TABLE_PICTURES']} for your pictures tables (ex: cpg133_pictures):


ALTER TABLE `{$CONFIG['TABLE_PICTURES']}` ADD `ptime` INT NOT NULL AFTER `ctime`;


Step 2: Modifying file "include/functions.inc.php"

2.1 Replace (line 899,900):


           'da' => 'pid ASC',
           'dd' => 'pid DESC',


with:


           'da' => 'ptime ASC, pid ASC',
           'dd' => 'ptime DESC, pid DESC',


Step 3: Modifying file "include/picmgmt.inc.php"

3.1 Add after (line 22 )


if($CONFIG['read_iptc_data'] ){
        include("include/iptc.inc.php");
}


this:


if($CONFIG['read_exif_data'] ){
        include("include/exif_php.inc.php");
}


3.2 Add before (line 97 )


    // Test if picture requires approval
    if (GALLERY_ADMIN_MODE) {


this:


     if ( $CONFIG['read_exif_data'])
     {
         $exif = exif_parse_file($image, 1);


         $size = count($exif);
     }

     if (isset($exif) && is_array($exif) && isset($exif['DateTime'])) {
         // Transform EXIF date format to unixtime
         $picture_time = mktime(substr($exif['DateTime'], 11, 2), substr($exif['DateTime'], 14, 2), substr($exif['DateTime'], 17, 2), substr($exif['DateTime'], 5, 2), substr($exif['DateTime'], 8, 2),   substr($exif['DateTime'], 0, 4) );
       $creation_time = time();
     }
     else
     {
         $picture_time = time();
         $creation_time = $picture_time;
     }



3.3 Add after  (line 142) (line 114 before above additions)


$CURRENT_PIC_DATA['pheight'] = $imagesize[1];


this:


    $CURRENT_PIC_DATA['ptime'] = $picture_time;

   
3.4 Replace ( line 158 ) (line 130 before above additions )


    $query = "INSERT INTO {$CONFIG['TABLE_PICTURES']} (aid, filepath, filename, filesize, total_filesize, pwidth, pheight, ctime, owner_id, owner_name, title, caption, keywords, approved, user1, user2, user3, user4, pic_raw_ip, pic_hdr_ip, position) VALUES ('{$CURRENT_PIC_DATA['aid']}', '" . addslashes($CURRENT_PIC_DATA['filepath']) . "', '" . addslashes($CURRENT_PIC_DATA['filename']) . "', '{$CURRENT_PIC_DATA['filesize']}', '{$CURRENT_PIC_DATA['total_filesize']}', '{$CURRENT_PIC_DATA['pwidth']}', '{$CURRENT_PIC_DATA['pheight']}', '" . time() . "', '{$CURRENT_PIC_DATA['owner_id']}', '{$CURRENT_PIC_DATA['owner_name']}','{$CURRENT_PIC_DATA['title']}', '{$CURRENT_PIC_DATA['caption']}', '{$CURRENT_PIC_DATA['keywords']}', '{$CURRENT_PIC_DATA['approved']}', '{$CURRENT_PIC_DATA['user1']}', '{$CURRENT_PIC_DATA['user2']}', '{$CURRENT_PIC_DATA['user3']}', '{$CURRENT_PIC_DATA['user4']}', '{$CURRENT_PIC_DATA['pic_raw_ip']}', '{$CURRENT_PIC_DATA['pic_hdr_ip']}', '{$CURRENT_PIC_DATA['position']}')";


with:


     $query = "INSERT INTO {$CONFIG['TABLE_PICTURES']} (aid, filepath, filename, filesize, total_filesize, pwidth, pheight, ctime, ptime, owner_id, owner_name, title, caption, keywords, approved, user1, user2, user3, user4, pic_raw_ip, pic_hdr_ip, position) VALUES ('{$CURRENT_PIC_DATA['aid']}', '" . addslashes($CURRENT_PIC_DATA['filepath']) . "', '" . addslashes($CURRENT_PIC_DATA['filename']) . "', '{$CURRENT_PIC_DATA['filesize']}', '{$CURRENT_PIC_DATA['total_filesize']}', '{$CURRENT_PIC_DATA['pwidth']}', '{$CURRENT_PIC_DATA['pheight']}', '" . time() . "', '{$CURRENT_PIC_DATA['ptime']}', '{$CURRENT_PIC_DATA['owner_id']}', '{$CURRENT_PIC_DATA['owner_name']}','{$CURRENT_PIC_DATA['title']}', '{$CURRENT_PIC_DATA['caption']}', '{$CURRENT_PIC_DATA['keywords']}', '{$CURRENT_PIC_DATA['approved']}', '{$CURRENT_PIC_DATA['user1']}', '{$CURRENT_PIC_DATA['user2']}', '{$CURRENT_PIC_DATA['user3']}', '{$CURRENT_PIC_DATA['user4']}', '{$CURRENT_PIC_DATA['pic_raw_ip']}', '{$CURRENT_PIC_DATA['pic_hdr_ip']}', '{$CURRENT_PIC_DATA['position']}')";



Step 4: Modifying file "include/exif_php.inc.php"

This step is necessary since only selected elements of the exif data are returned for display.  When calling the exif method when adding a file, all the exif data needs to be returned.

4.1 Replace (line 27)


  function exif_parse_file($filename)


with:


  function exif_parse_file($filename, $addfile )


4.2 Replace for loop: (line 85 )


         foreach ($exif as $key => $val) {
           if (strpos($showExifStr,"|".$key) && isset($val)){
                 $exifParsed[$lang_picinfo[$key]] = $val;
                 //$exifParsed[$key] = $val;
           }


with:


         foreach ($exif as $key => $val)
         {
             if ( $addfile == 0 )
             {
                if (strpos($showExifStr,"|".$key) && isset($val))
                {
                    $exifParsed[$lang_picinfo[$key]] = $val;
                }
             }
             else
                $exifParsed[$key] = $val;


Step 5: Modifying file "displayimage.php"

5.1 Replace ( line 152 )


     if ($CONFIG['read_exif_data']) $exif = exif_parse_file($path_to_pic);


with:


     if ($CONFIG['read_exif_data']) $exif = exif_parse_file($path_to_pic, 0);


Step 6: Modifying file "util.php"

6.1 Add Before: (line 54 )


        'del_titles' => array('del_titles', $lang_util_php['delete_title'], $lang_
util_php['delete_title_explanation']),


this:


'exif_date' => array('updatesortingdate', $lang_util_php['update_sort'],'<b>'. $lang_util_php['update_sort_what'] .' (2):</b><br />
        <input type="radio" name="dateselect" checked="checked" value="0" id="exif" class="nobg" /><label for="exif" accesskey="x" class="labelradio">'. $lang_util_php['update_sort_exif'] .'</label><br />
        <input type="radio" name="dateselect" value="1" id="cdate" class="nobg" /><label for="cdate" accesskey="c" class="labelradio">'.$lang_util_php['update_sort_creation'] .'</label><br /> <br />'),


6.2 Add Before:  (line 217)


function filloptions()


this:


function updatesortingdate()
{
     $albumid = $_POST['albumid'];
     $dateselect = $_POST['dateselect'];
     global $lang_util_php, $CONFIG;

     $query = "SELECT UNIX_TIMESTAMP(mtime) as mtime, {$CONFIG['TABLE_PICTURES']}.* FROM {$CONFIG['TABLE_PICTURES']} WHERE aid = '$albumid'";
     $result = MYSQL_QUERY($query);
     $num = mysql_numrows($result);

     $i = 0;
     while ($i < $num) {
         $filename = $CONFIG['fullpath'] . mysql_result($result, $i, "filepath") . mysql_result($result, $i, "filename");
         $pid = mysql_result($result, $i, "pid");
       $pdate = mysql_result($result, $i, "ctime");

         if($dateselect == '0')
         {
             $query = "SELECT * FROM {$CONFIG['TABLE_EXIF']} WHERE filename='$filename' ";
             $result2 = MYSQL_QUERY($query);

             if(mysql_numrows($result2) == 1)
             {
                 $exif = unserialize(mysql_result($result2, 0, "exifData"));

                 if (isset($exif) && is_array($exif) && isset($exif['DateTime']))
                 {
                     $pdate = mktime(substr($exif['DateTime'], 11, 2), substr($exif['DateTime'], 14, 2), substr($exif['DateTime'], 17, 2), substr($exif['DateTime'], 5, 2), substr($exif['DateTime'], 8, 2),       substr($exif['DateTime'], 0, 4) );
                 }

                 $newdate = date('Y:m:d H:i:s', $pdate);
             }
          else
         {
             $newdate = $lang_util_php['update_sort_no_exif'];
         }
     }
         else // Creation date
         {
               $newdate = date('Y:m:d H:i:s', $pdate);
         }

         print $lang_util_php['file'] . ': '. $filename.' &rArr; '. $newdate .'<br />';
         my_flush();

         $query = "UPDATE {$CONFIG['TABLE_PICTURES']} SET ptime='$pdate' WHERE pid='$pid' ";
         MYSQL_QUERY($query);

         ++$i;
     }
}


Step 7: Modifying the language files lang/english.php

7.1 Add after ( line 1907)


$lang_util_php = array(


this:


  'update_sort' => 'Update Sorting Date Filed',
  'update_sort_what' => 'Choose which date will be used to sort the pictures',
  'update_sort_exif' => 'Picture taken date - EXIF (If no date if found the upload
date will be used.)',
  'update_sort_creation' => 'Upload date',
  'update_sort_no_exif' => 'No EXIF data',



Step 8: Modifying the sorting date for your old pictures

Log in as Admin, go to the Admin Tools and follow the instruction for Update Sorting Date Field


I'll attempt to attach a patch file that will patch the 1.4.10 version.  Drop the file into the coppermine directory and run with:

patch -b -p1 < patch-sortByEXIF-1.4.10.txt


Thanks to Dannisk for this great mod 3 years ago.  I spent about an hour hacking the mod in and another hour creating the patch and writing this doc, ugh...

Gary

// Edit Apr 24 - Updated to include bioman's corrections below.  Thanks bioman

bioman

Wow !!

THAT IS GREAT NEWS !

Moderators, it might be a good idea to PIN this thread for a while...

SO many people begged for a good soul to port Dannisk's work for 1.4.x :-)

Now, I can upgrade (and test your work Crabboy :-) ) !
Talk about chance, I was currently working on changing ALL my directory names and picture table accordingly to remove all special characters... in order to plan this upgrade anyway !

Thanx again Crabboy (I'll soon come back to report my feedback)

bioman

Hi again !

It didn't take long before I cuold check !

The overall work seems to work perfectly FINE !
I have 2 galleries : one 1.3 (modified)... and one 1.4.10.
After this mod, the photos are shown the same way which, TO ME, is vital !!!!

Thanx again Crabboy !!!

ALTHOUGH, there are a few typos that need to be corrected...

In the util.php
1- The text area side has been cut so it's not that easy to import it if your a beginner...
Replace
'exif_date' => array('updatesortingdate', $lang_util_php['update_sort'],'
                <b>'. $lang_util_php['update_sort_what'] .' (2):<br />
        <input type="radio" name="dateselect" checked="checked" value="0" id="exif
" class="nobg" /><label for="exif" accesskey="x" class="labelradio">'. $lang_util_
php['update_sort_exif'] .'</label><br />
        <input type="radio" name="dateselect" value="1" id="cdate" class="nobg" />
<label for="cdate" accesskey="c" class="labelradio">'. $lang_util_php['update_sort
_creation'] .'</label><br /> <br />'),


By :

'exif_date' => array('updatesortingdate', $lang_util_php['update_sort'],'<b>'. $lang_util_php['update_sort_what'] .' (2):</b><br />
        <input type="radio" name="dateselect" checked="checked" value="0" id="exif" class="nobg" /><label for="exif" accesskey="x" class="labelradio">'. $lang_util_php['update_sort_exif'] .'</label><br />
        <input type="radio" name="dateselect" value="1" id="cdate" class="nobg" /><label for="cdate" accesskey="c" class="labelradio">'.$lang_util_php['update_sort_creation'] .'</label><br /> <br />'),<br />'),


2- the updatesortingdate function has { problems... MEANING YOU CAN'T EVEN OPEN THE UTIL PAGE !!!!

Replace
function updatesortingdate()
{
     $albumid = $_POST['albumid'];
     $dateselect = $_POST['dateselect'];
     global $lang_util_php, $CONFIG;

     $query = "SELECT UNIX_TIMESTAMP(mtime) as mtime, {$CONFIG['TABLE_PICTURES']}.* FROM $CONFIG['TABLE_PICTURES']} WHERE aid = '$albumid'";
     $result = MYSQL_QUERY($query);
     $num = mysql_numrows($result);

     $i = 0;
     while ($i < $num) {
         $filename = $CONFIG['fullpath'] . mysql_result($result, $i, "filepath") . mysql_result($result, $i, "filename");
         $pid = mysql_result($result, $i, "pid");
       $pdate = mysql_result($result, $i, "ctime");

         if($dateselect == '0')
         {
             $query = "SELECT * FROM {$CONFIG['TABLE_EXIF']} WHERE filename='$filename' ";
             $result2 = MYSQL_QUERY($query);

             if(mysql_numrows($result2) == 1)
             {
                 $exif = unserialize(mysql_result($result2, 0, "exifData"));

                 if (isset($exif) && is_array($exif) && isset($exif['DateTime']))
                 {
                     $pdate = mktime(substr($exif['DateTime'], 11, 2), substr($exif['DateTime'], 14, 2), substr($exif['DateTime'], 17, 2), substr($exif['DateTime'], 5, 2), substr($exif['DateTime'], 8, 2),       substr($exif['DateTime'], 0, 4) );
                 }

                 $newdate = date('Y:m:d H:i:s', $pdate);
           }
         else
         {
             $newdate = $lang_util_php['update_sort_no_exif'];
         }
                               else // Creation date
                               {
                                       $newdate = date('Y:m:d H:i:s', $pdate);
                               }

         print $lang_util_php['file'] . ': '. $filename.' &rArr; '. $newdate .'<br />';
         my_flush();

         $query = "UPDATE {$CONFIG['TABLE_PICTURES']} SET ptime='$pdate' WHERE pid='$pid' ";
         MYSQL_QUERY($query);

         ++$i;
     }
}


By :
function updatesortingdate()
{
     $albumid = $_POST['albumid'];
     $dateselect = $_POST['dateselect'];
     global $lang_util_php, $CONFIG;

     $query = "SELECT UNIX_TIMESTAMP(mtime) as mtime, {$CONFIG['TABLE_PICTURES']}.* FROM {$CONFIG['TABLE_PICTURES']} WHERE aid = '$albumid'";
     $result = MYSQL_QUERY($query);
     $num = mysql_numrows($result);

     $i = 0;
     while ($i < $num) {
         $filename = $CONFIG['fullpath'] . mysql_result($result, $i, "filepath") . mysql_result($result, $i, "filename");
         $pid = mysql_result($result, $i, "pid");
       $pdate = mysql_result($result, $i, "ctime");

         if($dateselect == '0')
         {
             $query = "SELECT * FROM {$CONFIG['TABLE_EXIF']} WHERE filename='$filename' ";
             $result2 = MYSQL_QUERY($query);

             if(mysql_numrows($result2) == 1)
             {
                 $exif = unserialize(mysql_result($result2, 0, "exifData"));

                 if (isset($exif) && is_array($exif) && isset($exif['DateTime']))
                 {
                     $pdate = mktime(substr($exif['DateTime'], 11, 2), substr($exif['DateTime'], 14, 2), substr($exif['DateTime'], 17, 2), substr($exif['DateTime'], 5, 2), substr($exif['DateTime'], 8, 2),       substr($exif['DateTime'], 0, 4) );
                 }

                 $newdate = date('Y:m:d H:i:s', $pdate);
             }
          else
         {
             $newdate = $lang_util_php['update_sort_no_exif'];
         }
     }
         else // Creation date
         {
               $newdate = date('Y:m:d H:i:s', $pdate);
         }

         print $lang_util_php['file'] . ': '. $filename.' &rArr; '. $newdate .'<br />';
         my_flush();

         $query = "UPDATE {$CONFIG['TABLE_PICTURES']} SET ptime='$pdate' WHERE pid='$pid' ";
         MYSQL_QUERY($query);

         ++$i;
     }
}


Finally, a smal addon if you're using the French language :
On the French.php, after line 1904 :
$lang_util_php = array(

Add :
  'update_sort' => 'Mettre à jour le champs qui permet de trier par date',
  'update_sort_what' => 'Choisir la date qui servira pour trier les photos',
  'update_sort_exif' => 'Date de la prise de photo - EXIF (S\'il n\'y a pas de date, la date du téléchargement sera utilisée.)',
  'update_sort_creation' => 'Date du téléchargement',
  'update_sort_no_exif' => 'Aucune donnée EXIF',


Now, if you're lazy ( :-) ), here's a zip file containing the 7 modified files :

Bye and thanx again Crabboy !

crabboy

Thanks bioman.  I built the post by cutting and pasting from the diff displayed in Putty and it looks like it wrapped some of the longer lines.  I also tried to preserve the ^M characters since many use it on Windows, but  it's difficult to keep track of them in the Linux shell.

I've Updated the exif_date and the updatesortingdate() sections to include your changes so the users only have to do it once.

The patchfile is still untested, but I think it should work.  it doesn't contain the handy work of human error. :)


Nick99

Hi,

i c&p the hack out off the posting and it is not working.

If i add new pictures it works fine but i can't update the old ones.

But first i had to correct this ...

'exif_date' => array('updatesortingdate', $lang_util_php['update_sort'],'<b>'. $lang_util_php['update_sort_what'] .' (2):</b><br />
        <input type="radio" name="dateselect" checked="checked" value="0" id="exif" class="nobg" /><label for="exif" accesskey="x" class="labelradio">'. $lang_util_php['update_sort_exif'] .'</label><br />
        <input type="radio" name="dateselect" value="1" id="cdate" class="nobg" /><label for="cdate" accesskey="c" class="labelradio">'.$lang_util_php['update_sort_creation'] .'</label><br /> <br />'),<br />'),


This "<br />')," at the end seems wrong because it causes a syntax error.

I replaced 'DateTime' with 'DateTimedigitized' because it works better for me.

I can't figure out why the admin tool doesn't work but it seems to me that the function is not called. Please check this.

Bye Nick


crabboy

Quote
This "<br />')," at the end seems wrong because it causes a syntax error.
Yes, it seems you are correct, I took a look at my source and I did not have the extra <br />

Here is the section as it appears on my machine:

        'exif_date' => array('updatesortingdate', $lang_util_php['update_sort'],'

                <b>'. $lang_util_php['update_sort_what'] .' (2):<br />       
                <input type="radio" name="dateselect" checked="checked" value="0" id="exif" class="nobg" /><label for="exif" accesskey="x" class="labelradio">'. $lang_util_php['update_sort_exif'] .'</label><br />       
                <input type="radio" name="dateselect" value="1" id="cdate" class="nobg" /><label for="cdate" accesskey="c" class="labelradio">'. $lang_util_php['update_sort_creation'] .'</label><br /> <br />'),

Forrest Gump

Hello, first of all thanx for great programming.

Quote from: Nick99 on May 05, 2007, 11:00:05 AM
i c&p the hack out off the posting and it is not working.

If i add new pictures it works fine but i can't update the old ones.

Is there a solution meanwhile? Sorry, but I can't figure it out. After successfuly doing the mod and updating the sortorder by exif in the admin-tools, there's no change at all.

`ptime` int(11) NOT NULL COMMENT 'exifmod',
`position` int(11) NOT NULL default '0',

All above fields in the DB table pictures were filled with "0"

With new pics it works fine, thanx again.

Gruß, Forrest  :-*

http://hellraisers.web157.webgo24-server11.de/hr-coppermine/thumbnails.php?album=4

Forrest Gump

 ;D Hello again,

I've found some errors and modified the "Sort by EXIF date mod port" so that it now works as it was indended to do. It's primarily desinged for "old" pictures, that have been in the DB before doing the "Sort by EXIF date mod port".



Affected files:

util.php, english.php (+ german.php + german_sie.php)



Step 1. regarding to Step 6: Modifying file "util.php" 6.1

Probably here I've found the biggest error, the old function updatesortingdate() never could be executed due to this part of the code:

'exif_date' => array('updatesortingdate',

It had to be the same name. I've corrected it and by the way use another name for the function, regarding to what it really does. Also I've added another option. Now there are 3 options:


  • EXIF DateTimeOriginal or nothing
  • EXIF DateTimeOriginal or Upload Date
  • Upload Date

Replace the code below with the one in Step 6: Modifying file "util.php" 6.1

// exifmod
  'put_date_to_ptime' => array(
                                'put_date_to_ptime',
                                $lang_util_php['put_ptime'],
                                '<b>'. $lang_util_php['put_ptime_what'].' (2):</b><br />
                                <input type="radio" name="choice" checked="checked" value="0" id="exif" class="nobg" /><label for="exif" class="labelradio">'. $lang_util_php['put_ptime_exif'] .'</label><br />
                                <input type="radio" name="choice" value="1" id="exif_or_upload" class="nobg" /><label for="exif_or_upload" class="labelradio">'. $lang_util_php['put_ptime_exif_or_upload'] .'</label><br />
                                <input type="radio" name="choice" value="2" id="upload" class="nobg" /><label for="upload" class="labelradio">'. $lang_util_php['put_ptime_upload'] .'</label><br /> <br />'
                              ),
// exifmodend




Step 2. regarding to Step 6: Modifying file "util.php" 6.2

Replace the code below with the one in Step 6: Modifying file "util.php" 6.2

// exifmod
function put_date_to_ptime()
{
  global $CONFIG, $lang_util_php;

  echo "<b>{$lang_util_php['put_ptime_wait']}</b><br /><br />";

  $choice = $_POST['choice'];
  $albumid = (isset($_POST['albumid'])) ? $_POST['albumid'] : 0;
  $albstr = ($albumid) ? "WHERE aid = $albumid" : '';
  $result = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_PICTURES']} $albstr");

  while ($row = mysql_fetch_assoc($result)){
    $fileadr = $CONFIG['fullpath'] . $row['filepath'] . $row['filename'];
    $pid = $row['pid'];
    $ctime = $row['ctime'];
    $filename = $row['filename'];

    switch ($choice){
      case 0: // put_ptime_exif
              if(read_exif_data("$fileadr")) {
                $exif = read_exif_data("$fileadr");
                $date = $exif['DateTimeOriginal'] ? $exif['DateTimeOriginal'] : '';
                $message = $date;
              }
              else {
                $date = '';
                $message = $date;
              }
              break;
      case 1: // put_ptime_exif_or_upload
              if(read_exif_data("$fileadr")) {
                $exif = read_exif_data("$fileadr");
                if($exif['DateTimeOriginal']) {
                  $date = $exif['DateTimeOriginal'];
                  $message = $date;
                }
                else {
                  $date = $ctime ? $ctime : '';
                  $message = $date . " <b>ctime</b>";
                }
              }
              break;
      case 2: // put_ptime_upload
              $date = date("Y:m:d H:i:s", $ctime);
              $message = $date . " <b>ctime</b>";
              break;
    }
    $date = mktime(substr($date, 11, 2), substr($date, 14, 2), substr($date, 17, 2), substr($date, 5, 2), substr($date, 8, 2), substr($date, 0, 4) );
    $query = cpg_db_query("UPDATE {$CONFIG['TABLE_PICTURES']} SET ptime = '$date' WHERE pid = '$pid'");
    if ($query) echo "<span style='white-space:nowrap'>" . $message . " => ptime (" . $filename . ")<span><br />";
  }
  echo "<br /><br /><b>{$lang_util_php['put_ptime_success']}</b><br /><br />";
}
// exifmodend


What the function does?

It just reads the EXIF DateTimeOriginal if present out of the original file, using the php function read_exif_data(), transforms it in UnixTimeStamp and writes it in the TABLE_PICTURES field ptime. Optionaly (and/or) reads the value of TABLE_PICTURES field ctime and writes it to ptime.

Thats all.

Comment:

It was much easier for me to read the EXIF data directly from the file, than out of the TABLE_EXIF, most of all only EXIF data of already seen pictures exist in TABLE_EXIF. Above all I used the DateTimeOriginal instead of DateTime, since some software seams to change the EXIF DateTime, but not the EXIF DateTimeOriginal.



Step 3. regarding to Step 7: Modifying the language files lang/english.php 7.1

Use code below instead

// exifmod
  'put_ptime' => 'Put date in DB (TABLES_PICTURES ptime) per feature "sort by date"',
  'put_ptime_what' => 'Choose which date will be used',
  'put_ptime_exif' => 'EXIF DateTimeOriginal (shooting date) (If not present - <b>empty field</b>)',
  'put_ptime_exif_or_upload' => 'EXIF DateTimeOriginal (shooting date) (If not present - <b>upload date</b>)',
  'put_ptime_upload' => 'upload date',
  'put_ptime_success' => 'Putting date in DB (TABLES_PICTURES ptime) succeeded',
// exifmodend


for german.php use code below

// exifmod
  'put_ptime' => 'Schreibe Datum in DB (TABLES_PICTURES ptime). Betrifft "Sortierung nach Datum"',
  'put_ptime_what' => 'W&auml;hle das gew&uuml;nschte Datum',
  'put_ptime_exif' => 'EXIF DateTimeOriginal (Aufnahmedatum) (Wenn nicht vorhanden, <b>leeres Feld</b>.)',
  'put_ptime_exif_or_upload' => 'EXIF DateTimeOriginal (Aufnahmedatum) (Wenn nicht vorhanden, <b>Upload Datum</b>.)',
  'put_ptime_upload' => 'Upload Datum',
  'put_ptime_wait' => 'Bitte warten, Felder "TABLES_PICTURES ptime" werden geschrieben',
  'put_ptime_success' => 'Daten erfolgreich in Datenbank (TABLES_PICTURES ptime) eingetragen',
// exifmodend


for german_sie.php use code below

/ /exifmod
  'put_ptime' => 'Schreibe Datum in DB (TABLES_PICTURES ptime). Betrifft "Sortierung nach Datum"',
  'put_ptime_what' => 'W&auml;hlen Sie das gew&uuml;nschte Datum',
  'put_ptime_exif' => 'EXIF DateTimeOriginal (Aufnahmedatum) (Wenn nicht vorhanden, <b>leeres Feld</b>.)',
  'put_ptime_exif_or_upload' => 'EXIF DateTimeOriginal (Aufnahmedatum) (Wenn nicht vorhanden, <b>Upload Datum</b>.)',
  'put_ptime_upload' => 'Upload Datum',
  'put_ptime_wait' => 'Bitte warten, Felder "TABLES_PICTURES ptime" werden geschrieben',
  'put_ptime_success' => 'Daten erfolgreich in Datenbank (TABLES_PICTURES ptime) eingetragen',
// exifmodend




Finally, but only if you want to show a hint to the new function on top of the admin-tools page, add the code below into english.php

after:

if (defined('UTIL_PHP')) {
$lang_util_desc_php = array(


add:

// exifmod
'Puts shooting date (EXIF DateTimeOriginal) <b>or</b> upload date to DB, per feature "sort by date"',
// exifmodend


into german.php and german_sie.php add:

// exifmod
'Schreibt Aufnahme-Datum (EXIF DateTimeOriginal) <b>oder</b> Upload-Datum in die DB, zur Sortierung nach Datum',
// exifmodend



Please let me know if it works, bye and thanxs to all, Forrest

apassio

I saw several incremental upgrades to this mod. I have just upgraded to cpg1.4.14.

Is there a total package / patch that can be used in one step to get this functionality of sorting by exif date.

Also, I am confused whether the mod will only apply to old pictures or also to newly uploaded ones.

Thanks

Joachim Müller

Quote from: apassio on November 19, 2007, 07:04:54 PM
Is there a total package / patch that can be used in one step to get this functionality of sorting by exif date.
No.

Megachip

Is it possible to create one? e.g. a plugin? Or include this directly into cpg?

Joachim Müller

This is not the feature requests board. This thread deals with a mod. Per definition, a mod requires code to be edited. You're welcome to convert this into a plugin. Currently, there is only this mod available, but no plugin that does the same. Please keep the discussion on this thread to what it was meant for.

diedhert

Can someone explain me how to alter a database (step1). Sorry if this is a dumb question.

Joachim Müller

You run a query in a third party tool like phpMyAdmin or in a custom PHP file. Might not be obvious to everyone: the stuff in curly brackets has to be replaced with the actual table name of coppermine's config table when running the query in phpMyAdmin.

diedhert

Thanks,

I applied all changes but the MOD does not seem to work.
I do not get any errors, but EXIF date (capture time, etc...) is not shown when viewing pictures, but it is shown when I replace the files with the ones where the mod is not installed.  The pictures are not sorted by capturer time.

So I presume something is wrong. However, I have poor knowledge of all these things. Where should I start to see why this mod is not working ? 

Thanks for any help.

ff

Quote from: diedhert on September 19, 2008, 08:06:47 AM
Thanks,

I applied all changes but the MOD does not seem to work.
I do not get any errors, but EXIF date (capture time, etc...) is not shown when viewing pictures, but it is shown when I replace the files with the ones where the mod is not installed.  The pictures are not sorted by capturer time.

So I presume something is wrong. However, I have poor knowledge of all these things. Where should I start to see why this mod is not working ? 

Thanks for any help.

In util.php I had to replace "DateTimeOriginal" by "DateTimedigitized" as my DateTimeOriginal is empty.
I now have entries in my records. But can't see if the sorting is working.

I had my pictures sorted by title which have the date typed in.

ThunderBoy

This i need to implant in version 1.5.8.
I tried it, but the source is already different and so good and i'm not a programmer.
I wonder why it is not yet been added to the new version.
Someone did not do a new version of some kind of mod? ???

In the gallery i have several albums in which i or one type of shift does not work correctly.
Photos of me throws all sorts, but not in the order, as were shot.

Also, i wonder why it is not already solved and the order for each album separately.
I had just recently done in http://www.gallery2.org/ photo gallery and have it there the treated perfectly.
I do not know why the coppermine do not use the information from Exif.. To go with the times.  ::)
I apologize for my english :)

Joachim Müller