diff options
author | plegall <plg@piwigo.org> | 2006-04-20 21:13:47 +0000 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2006-04-20 21:13:47 +0000 |
commit | 7e13640ad12c0b7be2fa3fbcf68f7a7441cb999c (patch) | |
tree | 5b9e5d1bb6b7ac5e8af52e19adc499cf1229cfe4 /tools | |
parent | c64da384ea354a194cfdcbd552340261b5d547d9 (diff) |
merge -r1221:1222 from branch 1.6 to trunk (bug 339)
git-svn-id: http://piwigo.org/svn/trunk@1223 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'tools')
-rw-r--r-- | tools/metadata.php | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/tools/metadata.php b/tools/metadata.php index 011240135..1ef307f3f 100644 --- a/tools/metadata.php +++ b/tools/metadata.php @@ -28,6 +28,25 @@ $filename = 'sample.jpg'; echo 'Informations are read from '.$filename.'<br /><br /><br />'; +/** + * return a cleaned IPTC value + * + * @param string value + * @return string + */ +function clean_iptc_value($value) +{ + // strip leading zeros (weird Kodak Scanner software) + while ( isset($value[0]) and $value[0] == chr(0)) + { + $value = substr($value, 1); + } + // remove binary nulls + $value = str_replace(chr(0x00), ' ', $value); + + return $value; +} + $iptc_result = array(); $imginfo = array(); getimagesize($filename, $imginfo); @@ -38,17 +57,25 @@ if (isset($imginfo['APP13'])) { foreach (array_keys($iptc) as $iptc_key) { - if (isset($iptc[$iptc_key][0]) and $value = $iptc[$iptc_key][0]) + if (isset($iptc[$iptc_key][0])) { - // strip leading zeros (weird Kodak Scanner software) - while ($value[0] == chr(0)) + if ($iptc_key == '2#025') + { + $value = implode( + ',', + array_map( + 'clean_iptc_value', + $iptc[$iptc_key] + ) + ); + } + else { - $value = substr($value, 1); + $value = clean_iptc_value($iptc[$iptc_key][0]); } - // remove binary nulls - $value = str_replace(chr(0x00), ' ', $value); + + $iptc_result[$iptc_key] = $value; } - $iptc_result[$iptc_key] = $value; } } |