Announcement

  •  » Engine
  •  » [resolved] Question about EXIFs

#1 2013-12-05 11:50:55

mistic100
Former Piwigo Team
Lyon (FR)
2008-09-27
3277

[resolved] Question about EXIFs

I am working on [Bugtracker] ticket 3009
and I have some questions :

- which are the keys holding GPS data ?

On many papers I see Exif.GPSInfo.GPSLatitudeRef, Exif.GPSInfo.GPSLatitude, etc.
But on "Map & Earth" and "Open Street Map", there is no mention of "GPSInfo" key, like data are located in Exif.GPSLatitudeRef, Exif.GPSLatitude, etc.

So which one is correct ? or does read_exif_data() applies some transformation ?


- how to add metadata sync in Piwigo ?

I mean, in any case it will need a special treatment in get_exif_data() because info came from four fields and is stored in two (plus conversion from degree/minute/second to decimal).

But, if I just update the default configuration $conf['use_exif_mapping'] many users overwriting this param won't have their  geotags synced if we don't tell them to update their config.
My idea is to always sync geotags as soon as $conf['use_exif'] is true.
Is it ok for you ?


- do I drop "lat" and "lon" fields during migration ?


- a word about IPTC
It would be interesting to have a plugin witch transform City/Province State/Country IPTC tags into approximate latitude/longitude (with the help of an external API I guess)

Offline

 

#2 2013-12-05 11:54:33

mistic100
Former Piwigo Team
Lyon (FR)
2008-09-27
3277

Re: [resolved] Question about EXIFs

off topic : why don't we try populate database with Exif.Image.ImageDescription and Exif.Photo.UserComment by default ? (cf. default value of $conf['use_exif_mapping'])

Offline

 

#3 2013-12-05 13:28:53

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: [resolved] Question about EXIFs

mistic100 wrote:

- which are the keys holding GPS data ?

Here are the functions I have extracted from rvelices plugin rv_gmaps and used in exif_view:

Code:

/**
 * GPS function stolen from plugin rv_gmaps
 */
function ev_parse_fract( $f )
{
  $nd = explode( '/', $f );

  if (0 == $nd[1])
  {
    return $nd[0];
  }
  
  return $nd[0]/$nd[1];
}

function ev_parse_lat_lon( $arr )
{
  $v=0;
  $v += ev_parse_fract( $arr[0] );
  $v += ev_parse_fract( $arr[1] )/60;
  $v += ev_parse_fract( $arr[2] )/3600;
  return $v;
}

function ev_exif_to_lat_lon( $exif )
{
  $exif = array_intersect_key( $exif, array_flip( array('GPSLatitudeRef', 'GPSLatitude', 'GPSLongitudeRef', 'GPSLongitude') ) );
  if ( count($exif)!=4 )
    return '';
  if ( !in_array($exif['GPSLatitudeRef'], array('S', 'N') ) )
    return 'GPSLatitudeRef not S or N';
  if ( !in_array($exif['GPSLongitudeRef'], array('W', 'E') ) )
    return 'GPSLongitudeRef not W or E';
  if (!is_array($exif['GPSLatitude']) or !is_array($exif['GPSLongitude']) )
    return 'GPSLatitude and GPSLongitude are not arrays';
  
  $lat = ev_parse_lat_lon( $exif['GPSLatitude'] );
  if ( $exif['GPSLatitudeRef']=='S' )
    $lat = -$lat;
  $lon = ev_parse_lat_lon( $exif['GPSLongitude'] );
  if ( $exif['GPSLongitudeRef']=='W' )
    $lon = -$lon;
  
  return array ($lat,$lon);
}

Considering $exif = @read_exif_data($photo_filename); // see include/functions_metadata

A print_r($exif) on a GPS photo gives:

...
    [GPS_IFD_Pointer] => 344
...
    [GPSVersion] => 
    [GPSLatitudeRef] => N
    [GPSLatitude] => Array
        (
            [0] => 41/1
            [1] => 54/1
            [2] => 9843/500
        )

    [GPSLongitudeRef] => E
    [GPSLongitude] => Array
        (
            [0] => 8/1
            [1] => 40/1
            [2] => 1833/125
        )

    [GPSAltitudeRef] =>
    [GPSAltitude] => 479/10
    [GPSTimeStamp] => Array
        (
            [0] => 17/1
            [1] => 58/1
            [2] => 16/1
        )

    [GPSSpeedRef] => K
    [GPSSpeed] => 141/5000
    [GPSDateStamp] => 2009:09:22
...

You can also take a look at how grum managed the GPS metadata in class http://piwigo.org/dev/browser/extension … egMetaData (I think Piwigo should use this class in the future to handle metadata)

mistic wrote:

- how to add metadata sync in Piwigo ?

I mean, in any case it will need a special treatment in get_exif_data() because info came from four fields and is stored in two (plus conversion from degree/minute/second to decimal).

For sure, the GPS fields are more complicated and can't be used "as is" from metadata to Piwigo properties. This is the advantage of class JpegMetaData over the core metadata functions of Piwigo: it "parses" metadata before using them.

mistic wrote:

My idea is to always sync geotags as soon as $conf['use_exif'] is true.
Is it ok for you ?

It sounds fine for me.

mistic wrote:

- do I drop "lat" and "lon" fields during migration ?

I think it only means that the 2 geolocation plugins have to adapt on new fields. It doesn't seem complicated.

mistic wrote:

- a word about IPTC
It would be interesting to have a plugin witch transform City/Province State/Country IPTC tags into approximate latitude/longitude (with the help of an external API I guess)

It sounds complicated. It will lead to very inaccurate geolocation :-/ (and it might be very slow depending on the API you try to use)

Offline

 

#4 2013-12-06 20:39:46

mistic100
Former Piwigo Team
Lyon (FR)
2008-09-27
3277

Re: [resolved] Question about EXIFs

Offline

 

#5 2015-03-05 15:06:26

bocman
Member
2015-02-18
42

Re: [resolved] Question about EXIFs

mistic100 wrote:

I am working on [Bugtracker] ticket 3009
- a word about IPTC
It would be interesting to have a plugin witch transform City/Province State/Country IPTC tags into approximate latitude/longitude (with the help of an external API I guess)

Hi!
Have you found this plugin?
Or do you know how use Map & Earth and Open Street Maps plugins with City/Province State/Country IPTC tags instead of latitude/longitude ?

Offline

 
  •  » Engine
  •  » [resolved] Question about EXIFs

Board footer

Powered by FluxBB

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