Announcement

#16 2017-09-02 18:25:11

eliz82
Member
Romania
2016-04-27
281

Re: Search metadata

@executive
i have looked into  "include/config_default.inc.php" and i think i understand what have you done.

i was not aware what

Code:

 $conf['use_exif_mapping'] and $conf['use_iptc_mapping']

can import tags into database. seems I'm still a piwigo noob :)

Code:

$conf['use_exif_mapping'] = array(
  'tags'                 => 'Model',
  );

the word 'tags' do the magic

so i have tried to import multiple parameters from exif as tags

1)

Code:

$conf['use_exif_mapping'] = array(
  'date_creation'        => 'DateTimeOriginal',
  'tags'                 => 'Make,Model',
  'tags'             => 'Make',
  );

not working ... only import last. (this is normal thinking how php define array)


2)

Code:

$conf['use_exif_mapping'] = array(
  'date_creation'        => 'DateTimeOriginal',
  'tags'                 => array('Model','Make')

  );

not working ... error

3)

Code:

$conf['use_exif_mapping'] = array(
  'date_creation'        => 'DateTimeOriginal',
  'tags'                 =>  'Model, Make'

  );

not working ... error

4)

Code:

$conf['use_exif_mapping'] = array(
  'date_creation'        => 'DateTimeOriginal',
  'tags'                 => 'Model',
  'keywords'             => 'Make',
  );

it's working.

so it seems we are limited to importing only two parameters from exif as tags.

if you use iptc kewords it's easy to import multiple tags. i have used comma "," as a separator, and it's seems it's working

Last edited by eliz82 (2017-09-03 16:50:36)

Offline

 

#17 2017-09-02 18:43:06

eliz82
Member
Romania
2016-04-27
281

Re: Search metadata

i have looked at the code from "/admin/include/function_metadata.php"

and i have modified this original code of the main "/include/function_metadata.php"
[Github] Piwigo file include/functions_metadata.inc.php@L164-L182

Code:

    // configured fields
    foreach ($map as $key => $field)
    {
      if (strpos($field, ';') === false)
      {
        if (isset($exif[$field]))
        {
          $result[$key] = $exif[$field];
        }
      }
      else
      {
        $tokens = explode(';', $field);
        if (isset($exif[$tokens[0]][$tokens[1]]))
        {
          $result[$key] = $exif[$tokens[0]][$tokens[1]];
        }
      }
    }

to this:

Code:

    // configured fields
    foreach ($map as $key => $field){
    
    // $map field is array
    if (is_array($field)) {
    $temp = array();
    foreach ($field as $key2 => $field2) {
      if (strpos($field2, ';') === false){
        if (isset($exif[$field2])){
          $temp[$key2] = $exif[$field2];
        }
        }
        else {
        $tokens2 = explode(';', $field2);
        if (isset($exif[$tokens2[0]][$tokens2[1]])){
          $temp[$key] = $exif[$tokens2[0]][$tokens2[1]];
        }
        }
    }
    $result[$key] = implode(',' , $temp);
    unset($temp);
    if (empty($result[$key])) {
      unset($result[$key]);
    }
    }
    // $map field is string
    else {
      if (strpos($field, ';') === false){
      if (isset($exif[$field])){
        $result[$key] = $exif[$field];
      }
      }
      else{
      $tokens = explode(';', $field);
      if (isset($exif[$tokens[0]][$tokens[1]])){
        $result[$key] = $exif[$tokens[0]][$tokens[1]];
      }
      }
    }
    
    }

my code checks if conf[use_exif_map] key value is array and return a comma concatenated result which is accepted by the /admin/include/functions_metadata.php
however i think it has some conflicts with Exif plugin. maybe someone from Piwigo Team with a better knowledge can write a better version of this mod.

then in local config use something like this:

Code:

$conf['use_exif_mapping'] = array(
  'date_creation' => 'DateTimeOriginal',
  'keywords' => array('Make','Model','UndefinedTag:0xA434','UndefinedTag:0x0095')
);

$conf['metadata_keyword_separator_regex'] = '/[,;]/';

now can define tags or keywords as an array.
i have removed dot "." from the regex because many lense names contain dot (example Canon EF 400mm F5.6L USM), so lensname will not be broken into smaller parts.

i just tested with an photo made with olympus camera (with exif 2.3) and all tree parameters where imported into tags: Maker, Camera model, Lens Name .

Last edited by eliz82 (2017-09-03 08:53:15)

Offline

 

#18 2017-09-02 19:25:44

executive
Member
2017-08-16
1214

Re: Search metadata

Nice work. Hopefully it won't cause any other conflicts.

Offline

 

#19 2017-09-12 10:53:08

eliz82
Member
Romania
2016-04-27
281

Re: Search metadata

seems someone have made a patch for IPTC to accept a list of parameters (array)
[Github] Piwigo issue #753

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact