Member
Member
ClicClac   2010-03-30, 17:17
#1

I'm using printImageMetadata('', false,'exifdata');

With Canon 20D, 50D, Exif DateTimeOriginal give 2006:05:24 10:08:14
With Canon 7D, it give 2010-03-12T14:04:36.00+01:00
Is it possible to have something more readable

Member
Member
sbillard   2010-03-31, 03:53
#2

But of course. The printImageMetadata just prints what your camera records. To get something more readable you will have to format the data yourself rather than using that function.

Member
Member
ClicClac   2010-03-31, 16:01
#3

Ok, I modify the printImageMetadata function:

.../...
echo "\n";
foreach ($exif as $field => $value) {
$display = $_zp_exifvars[$field][3];
if ($display) {
$label = $_zp_exifvars[$field][2];
echo "$label:";

        if ($field == "EXIFModel") $apn = $value;
        if ($field == "EXIFDateTimeOriginal") $value = exif_date($value, $apn);

        printEditable('image', $field, $editable, $editclass, $messageIfEmpty, false, $value);
        echo "\n";
    }
}
echo "\n\n";

.../...

function exif_date($date,$apn) {
//'Model' => string 'Canon EOS 50D' (length=13)
//50D: 'DateTimeOriginal' => string '2009:12:05 12:42:33' (length=19)

            //'Model' => string 'Canon EOS 7D' (length=12)
            //7D: DateTimeOriginal' => string '2010-02-20T15:07:05.24+01:00' (length=28)

            // -> 50D
            if (!preg_match("/7D/", $apn)) {
                $pieces = explode(' ', $date);
                list($yy, $mm, $dd) = explode(':', $pieces[0]);
                list($hh, $min, $ss) = explode(':', $pieces[1]);
                }
            // 7D
            else {
                $pieces = explode('T', $date);
                list($yy, $mm, $dd) = explode('-', $pieces[0]);
                $pieces_h = explode('.', $pieces[1]);
                list($hh, $min, $ss) = explode(':', $pieces_h[0]);
            }
            $timestamp = mktime((int) $hh, (int) $min, (int) $ss, (int) $mm, (int) $dd, (int) $yy, '-1');
            $date = date('d.m.Y à H:i',$timestamp);
            return $date;
}
Member
Member
Blue Dragonfly   2010-03-31, 17:14
#4

I would suggest that instead of checking for the camera model, check for the time format itself. I suspect that other cameras use the ISO-8601 time format as well, and it would be a pain to keep updating the script for each camera model, rather than using a RegEx or similar to identify the time format, and display it accordingly. That would be more effective, and less maintenance.

I know PHP's strftime function can format a date/time in ISO-8601 format, but am not sure if strtotime or a similar built-in function can parse it.

Just my thoughts, as a programmer (though not specifically for PHP)! :-)

Member
Member
sbillard   2010-03-31, 22:58
#5

strtotime will parse any valid time format.

Member
Member
ClicClac   2010-04-01, 05:09
#6

Many thanks!!!
I didn't know the strtotime function.

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.