Author Topic: Insert EXIF date correct field when checking for new files  (Read 9986 times)

0 Members and 1 Guest are viewing this topic.

Offline tomac

  • Pre-Newbie
  • Posts: 1
    • View Profile
    • http://voodoo.somoslopeor.com
Insert EXIF date correct field when checking for new files
« on: January 20, 2003, 10:03:35 PM »
Hi,
I've done a little mod for inserting the images when checking for new files; now the EXIF field date is read, and then the correct date is inserted for the image:

checkimages.php, line 117:
        $exif = read_exif_data ("/var/www/4images/data/media/".$cat_id."/".$image_media_file);
        if ($exif) {
          ereg("([0-9]{4}):([0-9]{2}):([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})", $exif["DateTime"], $mio);
          $image_date = mktime($mio[4],$mio[5],$mio[6],$mio[2],$mio[3],$mio[1]);        }

Offline Axel1

  • Pre-Newbie
  • Posts: 3
    • View Profile
Insert EXIF date correct field when checking for new files
« Reply #1 on: February 04, 2003, 12:32:41 AM »
This will work:
Code: [Select]
$exif = read_exif_data (ROOT_PATH.'data/media/'.$cat_id."/".$image_media_file);
ereg("([0-9]{4}):([0-9]{2}):([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})", $exif["DateTime"], $mio);
$image_date = mktime($mio[4],$mio[5],$mio[6],$mio[2],$mio[3],$mio[1]);


(No  :( for
Code: [Select]
:(!!

Offline iban

  • Pre-Newbie
  • Posts: 9
    • View Profile
Re: Insert EXIF date correct field when checking for new files
« Reply #2 on: September 06, 2005, 11:51:17 PM »
I have apply that mod and nothing worked for me...  :cry:
But I have been investigating... And, this works for me!!!  :D

Open the ./admin/checkimages.php file and Find:

Quote
$image_date = (!isset($HTTP_POST_VARS['image_date_'.$i])) ? time() : ((trim($HTTP_POST_VARS['image_date_'.$i] != "")) ?
"UNIX_TIMESTAMP('".trim($HTTP_POST_VARS['image_date_'.$i])."')" : time());


And replace by:
Quote
        if ((exif_imagetype(MEDIA_PATH.'/'.$cat_id.'/'.$image_media_file))!=FALSE) {

            $exif = read_exif_data (MEDIA_PATH.'/'.$cat_id.'/'.$image_media_file);

            $date="";

            if (isset($exif['DateTimeOriginal']))
               $date=$exif['DateTimeOriginal'];
            if (empty($date) && isset($exif['DateTime']))
               $date=$exif['DateTime'];

            if (!empty($date)) {
               $date=split(':',str_replace(' ',':',$date));
               $date="{$date[0]}-{$date[1]}-{$date[2]} {$date[3]}:{$date[4]}:{$date[5]}";
               $image_date=strtotime($date);
            } else {
               $image_date = (!isset($HTTP_POST_VARS['image_date_'.$i])) ? time() : ((trim($HTTP_POST_VARS['image_date_'.$i] != "")) ?
"UNIX_TIMESTAMP('".trim($HTTP_POST_VARS['image_date_'.$i])."')" : time());
            } else {
                $image_date = (!isset($HTTP_POST_VARS['image_date_'.$i])) ? time() : ((trim($HTTP_POST_VARS['image_date_'.$i] != "")) ?
"UNIX_TIMESTAMP('".trim($HTTP_POST_VARS['image_date_'.$i])."')" : time());

            }

Offline tiberias

  • Pre-Newbie
  • Posts: 1
    • View Profile
Re: Insert EXIF date correct field when checking for new files
« Reply #3 on: December 11, 2005, 08:33:38 PM »
Hi all,

first I want to thank all of you "official" coders for the great software you're doing. Not to forget thanking all the others that help improving the gallery.

but to come back to the problem ;-).... I tried both of the changes mentioned above to get the gallery to take the exif date instead of the file date, but I didn't get it working.
With the second one I get a "Parse error: parse error in /srv/www/htdocs/web22/html/4images/admin/checkimages.php on line 276" when trying to load the "Check new images" page.
I'm using 1.7.1 with the exif mod (maybe that could be a prob?). Is there anyone out there who could help me a bit or got that working already?

thanks!

regards, Markus

Offline Patrick81

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: Insert EXIF date correct field when checking for new files
« Reply #4 on: March 14, 2006, 06:29:37 PM »
Has someone now a working script to read the exif date when checking for new images?

Offline ch€ri{Bi}˛

  • Sr. Member
  • ****
  • Posts: 315
  • A PRoBLeM wIthOUt SoLuTioN Is NoT rEAllY a PRoBLeM
    • View Profile
    • Pat's Gallery
Re: Insert EXIF date correct field when checking for new files
« Reply #5 on: March 19, 2006, 04:17:00 PM »
here is the (working) code i use to insert exif date from original pictures, code which is a little different than the one posted by Axel1:

in admin/checkimages.php  find:
Quote
$image_date = (isset($HTTP_POST_VARS['image_date_'.$i])) ? ((trim($HTTP_POST_VARS['image_date_'.$i] != "")) ? "UNIX_TIMESTAMP('".trim($HTTP_POST_VARS['image_date_'.$i])."')" : time()) : time();

 and replace by :
Code: [Select]
//-------------------------------------------[ [Mod] Insert EXIF date correct field when checking for new files ]
//        $image_date = (isset($HTTP_POST_VARS['image_date_'.$i])) ? ((trim($HTTP_POST_VARS['image_date_'.$i] != "")) ? "UNIX_TIMESTAMP('".trim($HTTP_POST_VARS['image_date_'.$i])."')" : time()) : time(); //--- original code
$exif = read_exif_data (ROOT_PATH.'data/media/'.$cat_id."/".$image_media_file);
ereg("([0-9]{4}):([0-9]{2}):([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})", $exif["DateTimeOriginal"], $mio);
$image_date = (isset($exif["DateTimeOriginal"])) ? mktime($mio[4],$mio[5],$mio[6],$mio[2],$mio[3],$mio[1]) : ((isset($HTTP_POST_VARS['image_date_'.$i])) ? ((trim($HTTP_POST_VARS['image_date_'.$i] != "")) ? "UNIX_TIMESTAMP('".trim($HTTP_POST_VARS['image_date_'.$i])."')" : time()) : time());
//-------------------------------------------[/[Mod] Insert EXIF date correct field when checking for new files ]


 :!: you must have EXIF Support  enabled  with PHP (and files with EXIF fields) if you want it to work  :wink:
ch€ri{Bi}˛


Offline Patrick81

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: Insert EXIF date correct field when checking for new files
« Reply #6 on: March 19, 2006, 06:24:21 PM »
here is the (working) code i use to insert exif date from original pictures, code which is a little different than the one posted by Axel1:

in admin/checkimages.php  find:
Quote
$image_date = (isset($HTTP_POST_VARS['image_date_'.$i])) ? ((trim($HTTP_POST_VARS['image_date_'.$i] != "")) ? "UNIX_TIMESTAMP('".trim($HTTP_POST_VARS['image_date_'.$i])."')" : time()) : time();

 and replace by :
Code: [Select]
//-------------------------------------------[ [Mod] Insert EXIF date correct field when checking for new files ]
//        $image_date = (isset($HTTP_POST_VARS['image_date_'.$i])) ? ((trim($HTTP_POST_VARS['image_date_'.$i] != "")) ? "UNIX_TIMESTAMP('".trim($HTTP_POST_VARS['image_date_'.$i])."')" : time()) : time(); //--- original code
$exif = read_exif_data (ROOT_PATH.'data/media/'.$cat_id."/".$image_media_file);
ereg("([0-9]{4}):([0-9]{2}):([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})", $exif["DateTimeOriginal"], $mio);
$image_date = (isset($exif["DateTimeOriginal"])) ? mktime($mio[4],$mio[5],$mio[6],$mio[2],$mio[3],$mio[1]) : ((isset($HTTP_POST_VARS['image_date_'.$i])) ? ((trim($HTTP_POST_VARS['image_date_'.$i] != "")) ? "UNIX_TIMESTAMP('".trim($HTTP_POST_VARS['image_date_'.$i])."')" : time()) : time());
//-------------------------------------------[/[Mod] Insert EXIF date correct field when checking for new files ]


 :!: you must have EXIF Support  enabled  with PHP (and files with EXIF fields) if you want it to work  :wink:

perfect!
well done!

br
Pat