4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: tomac on January 20, 2003, 10:03:35 PM

Title: Insert EXIF date correct field when checking for new files
Post by: tomac 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]);        }
Title: Insert EXIF date correct field when checking for new files
Post by: Axel1 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]
:(!!
Title: Re: Insert EXIF date correct field when checking for new files
Post by: iban 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());

            }
Title: Re: Insert EXIF date correct field when checking for new files
Post by: tiberias 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
Title: Re: Insert EXIF date correct field when checking for new files
Post by: Patrick81 on March 14, 2006, 06:29:37 PM
Has someone now a working script to read the exif date when checking for new images?
Title: Re: Insert EXIF date correct field when checking for new files
Post by: ch€ri{Bi}˛ 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:
Title: Re: Insert EXIF date correct field when checking for new files
Post by: Patrick81 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
Title: Re: Insert EXIF date correct field when checking for new files
Post by: Rembrandt on March 22, 2006, 08:18:05 PM
Hi!

http://www.4homepages.de/forum/index.php?topic=11072.msg58059#msg58059

mfg Andi