Changeset 493 for trunk/admin


Ignore:
Timestamp:
Aug 25, 2004, 11:09:09 PM (20 years ago)
Author:
z0rglub
Message:

"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

Location:
trunk/admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/configuration.php

    r486 r493  
    211211$use_exif = ($conf['use_exif']=='true')?'USE_EXIF_YES':'USE_EXIF_NO';
    212212$use_iptc = ($conf['use_iptc']=='true')?'USE_IPTC_YES':'USE_IPTC_NO';
     213$show_exif = ($conf['show_exif']=='true')?'SHOW_EXIF_YES':'SHOW_EXIF_NO';
     214$show_iptc = ($conf['show_iptc']=='true')?'SHOW_IPTC_YES':'SHOW_IPTC_NO';
    213215
    214216//----------------------------------------------------- template initialization
     
    245247  $use_exif=>'checked="checked"',
    246248  $use_iptc=>'checked="checked"',
     249  $show_exif=>'checked="checked"',
     250  $show_iptc=>'checked="checked"',
    247251 
    248252  'L_CONFIRM'=>$lang['conf_confirmation'],
     
    314318  'L_USE_IPTC'=>$lang['conf_use_iptc'],
    315319  'L_USE_IPTC_INFO'=>$lang['conf_use_iptc_info'],
     320  'L_SHOW_EXIF'=>$lang['conf_show_exif'],
     321  'L_SHOW_EXIF_INFO'=>$lang['conf_show_exif_info'],
     322  'L_SHOW_IPTC'=>$lang['conf_show_iptc'],
     323  'L_SHOW_IPTC_INFO'=>$lang['conf_show_iptc_info'],
    316324 
    317325  'F_ACTION'=>add_session_id(PHPWG_ROOT_PATH.'admin.php?page=configuration')
  • trunk/admin/include/functions_metadata.php

    r486 r493  
    2626// +-----------------------------------------------------------------------+
    2727
    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  */
    35 function get_iptc_data($filename)
     28include_once(PHPWG_ROOT_PATH.'/include/functions_metadata.inc.php');
     29
     30function get_sync_iptc_data($file)
    3631{
    37   global $getimagesize_time;
    38    
    3932  $map = array(
    4033    'keywords'        => '2#025',
     
    4639  $datefields = array('date_creation', 'date_available');
    4740 
    48   $result = array();
    49  
    50   // Read IPTC data
    51   $iptc = array();
    52  
    53   $start = get_moment();
    54   getimagesize($filename, &$imginfo);
    55   $getimagesize_time+= get_moment() - $start;
    56  
    57   if (is_array($imginfo) and isset($imginfo['APP13']))
    58   {
    59     $iptc = iptcparse($imginfo['APP13']);
    60     if (is_array($iptc))
    61     {
    62       $rmap = array_flip($map);
    63       foreach (array_keys($rmap) as $iptc_key)
    64       {
    65         if (isset($iptc[$iptc_key][0]) and $value = $iptc[$iptc_key][0])
    66         {
    67           // strip leading zeros (weird Kodak Scanner software)
    68           while ($value[0] == chr(0))
    69           {
    70             $value = substr($value, 1);
    71           }
    72           // remove binary nulls
    73           $value = str_replace(chr(0x00), ' ', $value);
    74          
    75           foreach (array_keys($map, $iptc_key) as $pwg_key)
    76           {
    77             if (in_array($pwg_key, $datefields))
    78             {
    79               if ( preg_match('/(\d{4})(\d{2})(\d{2})/', $value, $matches))
    80               {
    81                 $value = $matches[1].'-'.$matches[2].'-'.$matches[3];
    82               }
    83               else
    84               {
    85                 continue;
    86               }
    87             }
    88             $result[$pwg_key] = $value;
    89           }
    90         }
    91       }
    92     }
    93   }
    94   return $result;
     41  $iptc = get_iptc_data($file, $map);
     42
     43  foreach ($iptc as $pwg_key => $value)
     44  {
     45    if (in_array($pwg_key, $datefields))
     46    {
     47      if ( preg_match('/(\d{4})(\d{2})(\d{2})/', $value, $matches))
     48      {
     49        $iptc[$pwg_key] = $matches[1].'-'.$matches[2].'-'.$matches[3];
     50      }
     51    }
     52  }
     53
     54  return $iptc;
    9555}
    9656
     
    9858{
    9959  global $conf;
    100 
    101 //   $conf['use_iptc'] = true;
    102 //   $conf['use_exif'] = true;
    10360 
    10461  $inserts = array();
     
    13390    if ($conf['use_iptc'])
    13491    {
    135       $iptc = get_iptc_data($file);
    136       foreach (array_keys($iptc) as $key)
    137       {
    138         $insert[$key] = "'".addslashes($iptc[$key])."'";
     92      $iptc = get_sync_iptc_data($file);
     93      if (count($iptc) > 0)
     94      {
     95        foreach (array_keys($iptc) as $key)
     96        {
     97          $insert[$key] = "'".addslashes($iptc[$key])."'";
     98        }
    13999      }
    140100    }
Note: See TracChangeset for help on using the changeset viewer.