Announcement

#1 2006-08-30 11:19:28

phgiraud
Member
2006-08-23
37

Map EXIF Data

In order to populate the database (especially with data entered in EXIFManager), here are my changes:

1. database MySQL
The date_creation field in the database has to be modified to store the time, so that it can be set with the picture-taken datetime:

Code:

table "images" field "date_creation" => change from "DATE" to "DATETIME"

2. include/config_local.inc.php

Code:

$conf['use_exif'] = true; // activate EXIF mapping
$conf['use_exif_mapping'] = array( // enter here the fields that will be used to populate the database
  'date_creation' => 'DateTimeOriginal',
  'name' => 'ImageDescription',
  'comment' => 'UserComment',
  'author' => 'Artist',
  );

These changes allow to populate the database fields in this way:
- date_creation with picture-taken datetime (given by the camera)
- name with ImageDescription (can be set with EXIFManager)
- comment with UserComment (can be set with EXIFManager)
- author with Artist (can be set with EXIFManager)

3. Unfortunately, these mapping does not correctly work as-is, and this file has to be modified:
admin/include/functions_metadata.php

Code:

function get_sync_exif_data($file)
{
  $result = array();
  $exif = exif_read_data ($filename,0,true);
  $result['date_creation'] = $exif['EXIF']['DateTimeOriginal'] ;
  $result['name'] = trim($exif['IFD0']['ImageDescription']);
  $result['author'] = trim($exif['IFD0']['Artist']);
  $result['comment'] = trim(substr($exif['IFD0']['UserComment'],8));
  if ($result['comment']==="") $result['comment'] = trim(substr($exif['EXIF']['UserComment'],8));
  return $result;
}

This last point is not very clean (redundancy with the $conf['use_exif_mapping'] array), but correctly works.
Note how the UserComment is got: the "ASCII   " header is ignored and the field is read from [IFD0] or [EXIF] "folder".

4. Last detail: the thumbnails tool-tip can display <comment>/<name> instead of file size.
include/category_default.inc.php

Code:

$thumbnail_title = $row['comment']." / ".$row['name'] ;

Last edited by phgiraud (2006-08-31 14:12:52)

Offline

 

#2 2006-09-02 01:24:37

Marco76
Member
2006-08-29
8

Re: Map EXIF Data

phgiraud wrote:

3. Unfortunately, these mapping does not correctly work as-is, and this file has to be modified:
admin/include/functions_metadata.php

Code:

function get_sync_exif_data($file)
{
  $result = array();
  $exif = exif_read_data ($filename,0,true);
  $result['date_creation'] = $exif['EXIF']['DateTimeOriginal'] ;
  $result['name'] = trim($exif['IFD0']['ImageDescription']);
  $result['author'] = trim($exif['IFD0']['Artist']);
  $result['comment'] = trim(substr($exif['IFD0']['UserComment'],8));
  if ($result['comment']==="") $result['comment'] = trim(substr($exif['EXIF']['UserComment'],8));
  return $result;
}

This one contains an error. The fourth line should be:

Code:

$exif = exif_read_data ($file,0,true);

And now it's working ;). Thanx!!

Offline

 

#3 2018-01-03 22:23:47

fulford
Member
2018-01-03
1

Re: Map EXIF Data

I think the above is out of date now.

1. Rather than creating  include/config_local.inc.php follow the instructions in config.inc.php and create local/config/config.inc.php

2. DateTimeOriginal is already mapped in the default config.inc.php so we just need to locate it in the file and add any other
mappings that are required.

NB.  "use_exif" is already set to true.

$conf['use_exif'] = true; // activate EXIF mapping

$conf['use_exif_mapping'] = array( // enter here the fields that will be used to populate the database
  'date_creation' => 'DateTimeOriginal',
  'name' => 'ImageDescription',
  'author' => 'Artist',
  );

3. The function function  "get_sync_exif_data($file)" is already defined and in a way that appears to this novice at least, to be incompatible with suggestions above. So caution being the better part of valor I have left it well alone. So far it has worked well for me.

Unfortunately mapping comment => UserComment has not worked

Last edited by fulford (2018-01-04 10:11:21)

Offline

 

#4 2018-01-04 03:05:11

executive
Member
2017-08-16
65

Re: Map EXIF Data

Of course it's out of date. This thread is eleven years old. I believe that the documentation has been long since updated.

Offline

 

Board footer

Powered by FluxBB

github twitter facebook google+ newsletter Donate Piwigo.org © 2002-2018 · Contact