source: trunk/include/functions_metadata.inc.php @ 493

Last change on this file since 493 was 493, checked in by z0rglub, 20 years ago

"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

  • 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// |                        functions_metadata.inc.php                     |
4// +-----------------------------------------------------------------------+
5// | application   : PhpWebGallery <http://phpwebgallery.net>              |
6// | branch        : BSF (Best So Far)                                     |
7// +-----------------------------------------------------------------------+
8// | file          : $RCSfile$
9// | last update   : $Date: 2004-08-25 21:09:09 +0000 (Wed, 25 Aug 2004) $
10// | last modifier : $Author: z0rglub $
11// | revision      : $Revision: 493 $
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/**
29 * returns informations from IPTC metadata, mapping is done at the beginning
30 * of the function
31 *
32 * @param string $filename
33 * @return array
34 */
35function get_iptc_data($filename, $map)
36{
37  $result = array();
38 
39  // Read IPTC data
40  $iptc = array();
41 
42  $imginfo = array();
43  getimagesize($filename, $imginfo);
44 
45  if (isset($imginfo['APP13']))
46  {
47    $iptc = iptcparse($imginfo['APP13']);
48    if (is_array($iptc))
49    {
50      $rmap = array_flip($map);
51      foreach (array_keys($rmap) as $iptc_key)
52      {
53        if (isset($iptc[$iptc_key][0]) and $value = $iptc[$iptc_key][0])
54        {
55          // strip leading zeros (weird Kodak Scanner software)
56          while ($value[0] == chr(0))
57          {
58            $value = substr($value, 1);
59          }
60          // remove binary nulls
61          $value = str_replace(chr(0x00), ' ', $value);
62         
63          foreach (array_keys($map, $iptc_key) as $pwg_key)
64          {
65            $result[$pwg_key] = $value;
66          }
67        }
68      }
69    }
70  }
71  return $result;
72}
73?>
Note: See TracBrowser for help on using the repository browser.