source: branches/1.4/tools/metadata.php @ 12792

Last change on this file since 12792 was 675, checked in by plg, 20 years ago

all headers adapted to new year 2005, happy new year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | PhpWebGallery - a PHP based picture gallery                           |
4// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
5// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | branch        : BSF (Best So Far)
8// | file          : $RCSfile$
9// | last update   : $Date: 2005-01-07 23:10:51 +0000 (Fri, 07 Jan 2005) $
10// | last modifier : $Author: plg $
11// | revision      : $Revision: 675 $
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';
29echo 'Informations are read from '.$filename.'<br /><br /><br />';
30
31$iptc_result = array();
32$imginfo = array();
33getimagesize($filename, $imginfo);
34if (isset($imginfo['APP13']))
35{
36  $iptc = iptcparse($imginfo['APP13']);
37  if (is_array($iptc))
38  {
39    foreach (array_keys($iptc) as $iptc_key)
40    {
41      if (isset($iptc[$iptc_key][0]) and $value = $iptc[$iptc_key][0])
42      {
43        // strip leading zeros (weird Kodak Scanner software)
44        while ($value[0] == chr(0))
45        {
46          $value = substr($value, 1);
47        }
48        // remove binary nulls
49        $value = str_replace(chr(0x00), ' ', $value);
50      }
51      $iptc_result[$iptc_key] = $value;
52    }
53  }
54
55  echo 'IPTC Fields in '.$filename.'<br />';
56  $keys = array_keys($iptc_result);
57  sort($keys);
58  foreach ($keys as $key)
59  {
60    echo '<br />'.$key.' = '.$iptc_result[$key];
61  }
62}
63else
64{
65  echo 'no IPTC information';
66}
67
68echo '<br /><br /><br />';
69echo 'EXIF Fields in '.$filename.'<br />';
70$exif = read_exif_data($filename);
71echo '<pre>';
72print_r($exif);
73echo '</pre>';
74?>
Note: See TracBrowser for help on using the repository browser.