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