Changeset 1223


Ignore:
Timestamp:
Apr 20, 2006, 11:13:47 PM (18 years ago)
Author:
plg
Message:

merge -r1221:1222 from branch 1.6 to trunk (bug 339)

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/functions_metadata.php

    r1127 r1223  
    5454    $iptc['keywords'] = preg_replace('/[.;]/', ',', $iptc['keywords']);
    5555    $iptc['keywords'] = preg_replace('/^,+|,+$/', '', $iptc['keywords']);
     56
     57    $iptc['keywords'] = implode(
     58      ',',
     59      array_unique(
     60        explode(
     61          ',',
     62          $iptc['keywords']
     63          )
     64        )
     65      );
    5666  }
    5767
  • trunk/tools/metadata.php

    r675 r1223  
    2929echo 'Informations are read from '.$filename.'<br /><br /><br />';
    3030
     31/**
     32 * return a cleaned IPTC value
     33 *
     34 * @param string value
     35 * @return string
     36 */
     37function 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
    3150$iptc_result = array();
    3251$imginfo = array();
     
    3958    foreach (array_keys($iptc) as $iptc_key)
    4059    {
    41       if (isset($iptc[$iptc_key][0]) and $value = $iptc[$iptc_key][0])
     60      if (isset($iptc[$iptc_key][0]))
    4261      {
    43         // strip leading zeros (weird Kodak Scanner software)
    44         while ($value[0] == chr(0))
     62        if ($iptc_key == '2#025')
    4563        {
    46           $value = substr($value, 1);
     64          $value = implode(
     65            ',',
     66            array_map(
     67              'clean_iptc_value',
     68              $iptc[$iptc_key]
     69              )
     70            );
    4771        }
    48         // remove binary nulls
    49         $value = str_replace(chr(0x00), ' ', $value);
     72        else
     73        {
     74          $value = clean_iptc_value($iptc[$iptc_key][0]);
     75        }
     76       
     77        $iptc_result[$iptc_key] = $value;
    5078      }
    51       $iptc_result[$iptc_key] = $value;
    5279    }
    5380  }
Note: See TracChangeset for help on using the changeset viewer.