4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started 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]); }
-
This will work:
$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 :(
!!
-
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:
$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:
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());
}
-
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
-
Has someone now a working script to read the exif date when checking for new images?
-
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:
$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 :
//-------------------------------------------[ [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:
-
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:
$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 :
//-------------------------------------------[ [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
-
Hi!
http://www.4homepages.de/forum/index.php?topic=11072.msg58059#msg58059
mfg Andi