[493] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[593] | 3 | // | PhpWebGallery - a PHP based picture gallery | |
---|
| 4 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
[675] | 5 | // | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
---|
[493] | 6 | // +-----------------------------------------------------------------------+ |
---|
[593] | 7 | // | branch : BSF (Best So Far) |
---|
[493] | 8 | // | file : $RCSfile$ |
---|
| 9 | // | last update : $Date: 2007-03-12 22:33:53 +0000 (Mon, 12 Mar 2007) $ |
---|
| 10 | // | last modifier : $Author: rub $ |
---|
| 11 | // | revision : $Revision: 1900 $ |
---|
| 12 | // +-----------------------------------------------------------------------+ |
---|
| 13 | // | This program is free software; you can redistribute it and/or modify | |
---|
| 14 | // | it under the terms of the GNU General Public License as published by | |
---|
| 15 | // | the Free Software Foundation | |
---|
| 16 | // | | |
---|
| 17 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 18 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 19 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 20 | // | General Public License for more details. | |
---|
| 21 | // | | |
---|
| 22 | // | You should have received a copy of the GNU General Public License | |
---|
| 23 | // | along with this program; if not, write to the Free Software | |
---|
| 24 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
| 25 | // | USA. | |
---|
| 26 | // +-----------------------------------------------------------------------+ |
---|
| 27 | |
---|
| 28 | $filename = 'sample.jpg'; |
---|
| 29 | echo 'Informations are read from '.$filename.'<br /><br /><br />'; |
---|
| 30 | |
---|
[1223] | 31 | /** |
---|
| 32 | * return a cleaned IPTC value |
---|
| 33 | * |
---|
| 34 | * @param string value |
---|
| 35 | * @return string |
---|
| 36 | */ |
---|
| 37 | function clean_iptc_value($value) |
---|
| 38 | { |
---|
| 39 | // strip leading zeros (weird Kodak Scanner software) |
---|
| 40 | while ( isset($value[0]) and $value[0] == chr(0)) |
---|
| 41 | { |
---|
| 42 | $value = substr($value, 1); |
---|
| 43 | } |
---|
| 44 | // remove binary nulls |
---|
| 45 | $value = str_replace(chr(0x00), ' ', $value); |
---|
| 46 | |
---|
| 47 | return $value; |
---|
| 48 | } |
---|
| 49 | |
---|
[493] | 50 | $iptc_result = array(); |
---|
| 51 | $imginfo = array(); |
---|
| 52 | getimagesize($filename, $imginfo); |
---|
| 53 | if (isset($imginfo['APP13'])) |
---|
| 54 | { |
---|
| 55 | $iptc = iptcparse($imginfo['APP13']); |
---|
| 56 | if (is_array($iptc)) |
---|
| 57 | { |
---|
| 58 | foreach (array_keys($iptc) as $iptc_key) |
---|
| 59 | { |
---|
[1223] | 60 | if (isset($iptc[$iptc_key][0])) |
---|
[493] | 61 | { |
---|
[1223] | 62 | if ($iptc_key == '2#025') |
---|
[493] | 63 | { |
---|
[1223] | 64 | $value = implode( |
---|
| 65 | ',', |
---|
| 66 | array_map( |
---|
| 67 | 'clean_iptc_value', |
---|
| 68 | $iptc[$iptc_key] |
---|
| 69 | ) |
---|
| 70 | ); |
---|
[493] | 71 | } |
---|
[1223] | 72 | else |
---|
| 73 | { |
---|
| 74 | $value = clean_iptc_value($iptc[$iptc_key][0]); |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | $iptc_result[$iptc_key] = $value; |
---|
[493] | 78 | } |
---|
| 79 | } |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | echo 'IPTC Fields in '.$filename.'<br />'; |
---|
| 83 | $keys = array_keys($iptc_result); |
---|
| 84 | sort($keys); |
---|
| 85 | foreach ($keys as $key) |
---|
| 86 | { |
---|
| 87 | echo '<br />'.$key.' = '.$iptc_result[$key]; |
---|
| 88 | } |
---|
| 89 | } |
---|
| 90 | else |
---|
| 91 | { |
---|
| 92 | echo 'no IPTC information'; |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | echo '<br /><br /><br />'; |
---|
| 96 | echo 'EXIF Fields in '.$filename.'<br />'; |
---|
| 97 | $exif = read_exif_data($filename); |
---|
| 98 | echo '<pre>'; |
---|
| 99 | print_r($exif); |
---|
| 100 | echo '</pre>'; |
---|
| 101 | ?> |
---|