diff options
author | z0rglub <z0rglub@piwigo.org> | 2004-08-25 21:09:09 +0000 |
---|---|---|
committer | z0rglub <z0rglub@piwigo.org> | 2004-08-25 21:09:09 +0000 |
commit | d8494248fc3df1ac9b688fd5b250de60a50361b2 (patch) | |
tree | 209664043b3f2014be7acd492ba5a3b690c11883 /admin/include | |
parent | 593574214c8dcbd9fa5bb79060d9bbbc81ffd1fc (diff) |
"show metadata" feature added : you can ask to show metadata (EXIF and IPTC)
on picture.php page. Metadata read functions were moved from
admin/include/functions_metadata.php to include/functions_metadata.inc.php
git-svn-id: http://piwigo.org/svn/trunk@493 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin/include')
-rw-r--r-- | admin/include/functions_metadata.php | 74 |
1 files changed, 17 insertions, 57 deletions
diff --git a/admin/include/functions_metadata.php b/admin/include/functions_metadata.php index 9a7d45193..14d5a0d16 100644 --- a/admin/include/functions_metadata.php +++ b/admin/include/functions_metadata.php @@ -25,17 +25,10 @@ // | USA. | // +-----------------------------------------------------------------------+ -/** - * returns informations from IPTC metadata, mapping is done at the beginning - * of the function - * - * @param string $filename - * @return array - */ -function get_iptc_data($filename) +include_once(PHPWG_ROOT_PATH.'/include/functions_metadata.inc.php'); + +function get_sync_iptc_data($file) { - global $getimagesize_time; - $map = array( 'keywords' => '2#025', 'date_creation' => '2#055', @@ -45,61 +38,25 @@ function get_iptc_data($filename) ); $datefields = array('date_creation', 'date_available'); - $result = array(); - - // Read IPTC data - $iptc = array(); - - $start = get_moment(); - getimagesize($filename, &$imginfo); - $getimagesize_time+= get_moment() - $start; - - if (is_array($imginfo) and isset($imginfo['APP13'])) + $iptc = get_iptc_data($file, $map); + + foreach ($iptc as $pwg_key => $value) { - $iptc = iptcparse($imginfo['APP13']); - if (is_array($iptc)) + if (in_array($pwg_key, $datefields)) { - $rmap = array_flip($map); - foreach (array_keys($rmap) as $iptc_key) + if ( preg_match('/(\d{4})(\d{2})(\d{2})/', $value, $matches)) { - if (isset($iptc[$iptc_key][0]) and $value = $iptc[$iptc_key][0]) - { - // strip leading zeros (weird Kodak Scanner software) - while ($value[0] == chr(0)) - { - $value = substr($value, 1); - } - // remove binary nulls - $value = str_replace(chr(0x00), ' ', $value); - - foreach (array_keys($map, $iptc_key) as $pwg_key) - { - if (in_array($pwg_key, $datefields)) - { - if ( preg_match('/(\d{4})(\d{2})(\d{2})/', $value, $matches)) - { - $value = $matches[1].'-'.$matches[2].'-'.$matches[3]; - } - else - { - continue; - } - } - $result[$pwg_key] = $value; - } - } + $iptc[$pwg_key] = $matches[1].'-'.$matches[2].'-'.$matches[3]; } } } - return $result; + + return $iptc; } function update_metadata($files) { global $conf; - -// $conf['use_iptc'] = true; -// $conf['use_exif'] = true; $inserts = array(); @@ -132,10 +89,13 @@ function update_metadata($files) if ($conf['use_iptc']) { - $iptc = get_iptc_data($file); - foreach (array_keys($iptc) as $key) + $iptc = get_sync_iptc_data($file); + if (count($iptc) > 0) { - $insert[$key] = "'".addslashes($iptc[$key])."'"; + foreach (array_keys($iptc) as $key) + { + $insert[$key] = "'".addslashes($iptc[$key])."'"; + } } } |