[metadata] Convert IPTC location data to GPS #318

Open
opened 2026-10-04 23:51:56 +02:00 by adam · 2 comments
Owner

Reported by xbgmsharp on 19 Mar 2015 17:19

Version: 2.7.4

From http://piwigo.org/forum/viewtopic.php?pid=158156#p158156

Hello!
Unfortunately most of my photos haven't had GPS coordinates because they was scaned or made photo by camera without GPS.

I have marked IPTC position/city/state/country for them and it will be good idea!

I have a few thinks about how it will be good to work:

  • Many places may be out of cities, but may contain searchable names (for example "Sognefjorden" is the fjord in Norway. I can search it by Google maps (https://www.google.com/maps/place/Sogne … b81323cb38), but cann't search it by http://stevemorse.org/jcal/latlon.php because I nave to type city in this service)
  • It will be good if OpenStreetMap read ("city" OR/and "state") and "country" OR "position" (free text, like "Sognefjorden") if "city" is empty (for example)
  • If it worked with not only English (like Google Maps) it would be great!

In attachment photo with filled IPTC fields Country = "Norway" and Position "Norway, Sognefjorden"
http://media.aronov.su/tools/metadata.php show for it file:
2#005 = Ñîãíå-ôüîðä
2#025 = Sognefjorden,Íîðâåãèÿ,Ñîãíå-ôüîðä
2#080 = Leonid Aronov
2#092 = Norway, Sognefjorden
2#101 = Norway
2#116 = Leonid Aronov

Piwigo Bugtracker #3213

**Reported by xbgmsharp on 19 Mar 2015 17:19** **Version:** 2.7.4 From http://piwigo.org/forum/viewtopic.php?pid=158156#p158156 Hello! Unfortunately most of my photos haven&#039;t had GPS coordinates because they was scaned or made photo by camera without GPS. I have marked IPTC position/city/state/country for them and it will be good idea! I have a few thinks about how it will be good to work: - Many places may be out of cities, but may contain searchable names (for example &quot;Sognefjorden&quot; is the fjord in Norway. I can search it by Google maps (https://www.google.com/maps/place/Sogne … b81323cb38), but cann&#039;t search it by http://stevemorse.org/jcal/latlon.php because I nave to type city in this service) - It will be good if OpenStreetMap read (&quot;city&quot; OR/and &quot;state&quot;) and &quot;country&quot; OR &quot;position&quot; (free text, like &quot;Sognefjorden&quot;) if &quot;city&quot; is empty (for example) - If it worked with not only English (like Google Maps) it would be great! In attachment photo with filled IPTC fields Country = &quot;Norway&quot; and Position &quot;Norway, Sognefjorden&quot; http://media.aronov.su/tools/metadata.php show for it file: 2#005 = Ñîãíå-ôüîðä 2#025 = Sognefjorden,Íîðâåãèÿ,Ñîãíå-ôüîðä 2#080 = Leonid Aronov 2#092 = Norway, Sognefjorden 2#101 = Norway 2#116 = Leonid Aronov [Piwigo Bugtracker #3213](http://piwigo.org/bugs/view.php?id=3213) <!-- github-sync-id:97252312 -->
Author
Owner

Comment posted by xbgmsharp on 19 Mar 2015 17:20

A working PoC.

Install curl module for PHP
Code:

apt-get install php5-curl

Add in you configuration the following parameters:
Code:
$conf['show_iptc'] = true;
$conf['use_iptc'] = true;
$conf['iptc_to_gps'] = true;
$conf['show_iptc_mapping'] = array(
'iptc_keywords' => '2#025',
'iptc_caption_writer' => '2#122',
'iptc_byline_title' => '2#085',
'iptc_caption' => '2#120',
'iptc_country' => '2#101',
'iptc_countrycode' => '2#100',
'iptc_state' => '2#095',
'iptc_sublocation' => '2#092',
'iptc_city' => '2#090',
);

Replace the file /include/functions_metadata.inc.php by the one attach.

When you sync metadata, it will populate the latitude and longitude with the data from http://nominatim.openstreetmap.org if any.

**Comment posted by xbgmsharp on 19 Mar 2015 17:20** A working PoC. Install curl module for PHP Code: # apt-get install php5-curl Add in you configuration the following parameters: Code: $conf[&#039;show_iptc&#039;] = true; $conf[&#039;use_iptc&#039;] = true; $conf[&#039;iptc_to_gps&#039;] = true; $conf[&#039;show_iptc_mapping&#039;] = array( &#039;iptc_keywords&#039; =&gt; &#039;2#025&#039;, &#039;iptc_caption_writer&#039; =&gt; &#039;2#122&#039;, &#039;iptc_byline_title&#039; =&gt; &#039;2#085&#039;, &#039;iptc_caption&#039; =&gt; &#039;2#120&#039;, &#039;iptc_country&#039; =&gt; &#039;2#101&#039;, &#039;iptc_countrycode&#039; =&gt; &#039;2#100&#039;, &#039;iptc_state&#039; =&gt; &#039;2#095&#039;, &#039;iptc_sublocation&#039; =&gt; &#039;2#092&#039;, &#039;iptc_city&#039; =&gt; &#039;2#090&#039;, ); Replace the file /include/functions_metadata.inc.php by the one attach. When you sync metadata, it will populate the latitude and longitude with the data from http://nominatim.openstreetmap.org if any. <!-- github-comment-id:124899254 -->
Author
Owner

Comment posted by xbgmsharp on 19 Mar 2015 17:49

The code does the following:

  • Check for $conf['iptc_to_gps'] to be true.
  • Check for any of the location IPTC metadata are present
  • If any run a CURL query to nominatim.openstreetmap.org
  • If any reply, check for lat and lon.
  • If any valid lat and lon return it an array to be sync in the database.
**Comment posted by xbgmsharp on 19 Mar 2015 17:49** The code does the following: - Check for $conf[&#039;iptc_to_gps&#039;] to be true. - Check for any of the location IPTC metadata are present - If any run a CURL query to nominatim.openstreetmap.org - If any reply, check for lat and lon. - If any valid lat and lon return it an array to be sync in the database. <!-- github-comment-id:124899271 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#318