• Resolved owh

    (@owh)


    I can’t find the geo-tag EXIF (longitude, latitude) in the drop down menu to map to my custom fields.

    I have a plugin that has created a few custom fields including longitude and latitude of geo-tagged images. The plugin uses these fields to display the location of the image on a map. For new upload, these fields are populated automatically by the plugin from the image file EXIF. I have more than thousand of existing images (uploaded before the plugin is installed) that I would like to populate the custom fields from their EXIF. Your plugin seems to be almost able to do it. Is that possible? How can I achieve that?

    Thanks for the great plugin.

    http://wordpress.org/plugins/media-library-assistant/

Viewing 15 replies - 1 through 15 (of 16 total)
  • Plugin Author David Lingren

    (@dglingren)

    I’m happy to hear you appreciate the plugin, and I am sure we can find a way to extract the geo-tag information from your images.

    On the Settings/Media Library Assistant IPTC/EXIF tab, the “EXIF Value” column has a text box where you can enter the name of any EXIF field. The trick, sometimes, is finding the exact name of the field you want. For example, to access the UserComment field in the COMPUTED array you enter COMPUTED.UserComment.

    MLA uses a standard PHP function, exif_read_data, to extract EXIF data from images. It’s possible that the data you want is not being extracted by that function. WordPress 3.6 has added the getID3() code library, and I might be able to use that to retrieve additional data.

    If you can post a link to one or more of the images you’d like to process I can examine them and give you a more specific answer. If you can’t post a link, you can contact me through our web site and I will send you an e-mail address to which you can send them. Write me from the “Contact Us” page at our web site:

    Fair Trade Judaica/Contact Us

    Thanks for your interest and for your patience.

    Plugin Author David Lingren

    (@dglingren)

    Thank you for sending me four of your images for my investigation. I am using the metadata embedded in your “CIMG2510_reduced” image as an example.

    You are interested in four data elements:

    • Camera model
    • Latitude
    • Longtitude
    • Altitude

    There are two EXIF fields related to “Camera model”:

    • ‘Make’ => ‘CASIO COMPUTER CO.,LTD.’
    • ‘Model’ => ‘EX-ZR100 ‘,

    The ‘Model’ value is also available in the WordPress image_meta array as ‘camera’. You can enter “Make” or “Model” as the “EXIF Value” on the Settings/Media Library Assistant IPTC/EXIF tab to map these to a custom field. In my next version (v1.50) you will be able to combine the two values into a single custom field using the new Content Template feature I am adding in that release.

    The GPS information is more complicated. In Adobe Photoshop, the “File/File Info…” dialog box, Raw Data tab reports this information as:

    <exif:GPSVersionID>2.2.0.0</exif:GPSVersionID>
    <exif:GPSLatitude>44,7.5669N</exif:GPSLatitude>
    <exif:GPSLongitude>145,5.1534E</exif:GPSLongitude>
    <exif:GPSAltitudeRef>0</exif:GPSAltitudeRef>
    <exif:GPSAltitude>230528/933</exif:GPSAltitude>
    <exif:GPSTimeStamp>2013-08-09T01:00:34-07:00</exif:GPSTimeStamp>
    <exif:GPSMapDatum>WGS-84</exif:GPSMapDatum>

    The PHP function that MLA uses to extract EXIF data (exif_read_data) returns this information as:

    'GPSVersion' => a four-byte binary value,
      'GPSLatitudeRef' => 'N',
      'GPSLatitude' =>
      array (
        0 => '44/1',
        1 => '7/1',
        2 => '50923/1497',
      ),
      'GPSLongitudeRef' => 'E',
      'GPSLongitude' =>
      array (
        0 => '145/1',
        1 => '5/1',
        2 => '38746/4209',
      ),
      'GPSAltitudeRef' => a one-byte binary value,
      'GPSAltitude' => '230528/933',
      'GPSTimeStamp' =>
      array (
        0 => '1/1',
        1 => '0/1',
        2 => '34/1',
      ),
      'GPSMapDatum' => 'WGS-84',
      'GPSDateStamp' => '2013:08:09',

    The MLA EXIF mapping logic will convert the array values to comma-delimited strings. For example, ‘GPSLatitude’ will be mapped to “44/1,7/1,50923/1497”. The next MLA version (1.50) will let you store array values in a custom field without converting them to a string representation.

    The Exif Standard version 2.3 (http://www.cipa.jp/english/hyoujunka/kikaku/pdf/DC-008-2010_E.pdf) document explains the structure of the above data and defines the rules for 32 GPS elements. For example:

    GPSLatitude
    Indicates the latitude. The latitude is expressed as three RATIONAL values giving the degrees, minutes, and seconds, respectively. If latitude is expressed as degrees, minutes and seconds, a typical format would be dd/1,mm/1,ss/1. When degrees and minutes are used and, for example, fractions of minutes are given up to two decimal places, the format would be dd/1,mmmm/100,0/1.

    Using the above definition I am not sure how to get from 5669 seconds in Photoshop to the ‘50923/1497’ value returned by exif_read_data.

    As an experiment I also used the getID3() library to decode the metadata. It returns the same values as exif_read_data, but it also has a “computed” array of GPS information that contains:

    altitude double 247.08252947481
    latitude double 44.126115750019
    longitude double 145.08589042
    timestamp integer 943923634
    version string (8) v2.2.0.0

    I don’t know if this decoding would be of more interest to you.

    In summary, the GPS information is available and MLA can map it to custom fields for you. However, the format of the data might not be what you want. You could add some PHP code to your theme to convert the data to a more convenient format. There is no logic in the current or next MLA to process this data.

    I hope this helps you get the data you need from your images.

    Plugin Author David Lingren

    (@dglingren)

    Well, I did solve one mystery.

    The Latitude value 44,7.5669N is in “degrees and decimal minutes” format. If you take the returned “rational” value of ‘50923/1497’ and do the math it becomes 34.0167 seconds. Divide by 60 and you get 0.5669 minutes.

    The “double 44.126115750019” value in the “computed” array is the same value expressed in “decimal degrees”; 44 + (7.5669 / 60).

    Thread Starter owh

    (@owh)

    David, very much appreciate your time in working on this matter. Thanks a lot.

    It looks like you have solved the mystery of the maths behind the numbers. When I check the field populated by the plugin to display the given image, it is using the computed values for latitude and longitude, i.e. 44.12611575 and 145.08589042 respectively. I am sure there are other plugins that will use the data in different format i.e. the 44,7.5669N and 145,5.1534E.

    If I understand correctly, current MLA will provide a CVS string for GPSLatitude and GPSLongitude. I will wait for the next version to deal with this. I hope you can provide both the formats (44,7.5669N; 145,5.1534E and computed values of 44.12611575; 145.08589042).

    Thanks a lot again. This is extremely helpful.

    Plugin Author David Lingren

    (@dglingren)

    Because the default GPS data is in an inconvenient format I have added a variety of enhanced GPS values to my next version (1.50). The values you need will be accessed as “GPS.LatitudeDM”, “GPS.LongitudeDM”, “GPS.LatitudeDD” and “GPS.LongitudeDD”.

    You will also have access to each part of each value, e.g., “GPS.LatitudeMinDec” for the decimal minutes portion of the value. You can use the new Content Template feature to combine the parts in any format that you need.

    The new version will be out shortly; I hope it satisfies your requirements for access to geo-tag information. Thanks again for your interest and for motivating a great new feature.

    By the way, I would like to know what plugin you are using to populate these fields. Is it available in the Repository or did you develop it yourself? Thanks for any information you can give me.

    Thread Starter owh

    (@owh)

    I am using Fullscreen Galleria. In fact I am looking for plugin that can just display the location of the images on the post – without me having to do anything apart from inserting a shortcode. Fullscreen Galleria is the closest (to see the location of an image), however it can’t display map on the post (only view in lightbox when ‘M’ key is hit) and neither handle map of multiple image. The others (incl sophisticated map plugins) require unnecessary human working time when machine can simply extract the info automatically. I believe it is straight forward for those well versed in the technologies to make a plugin that I can simply insert a shortcode of [map_of_images_on_this_post] or [location_of_this_image] in the post or side bar and it will take care of everything. I am still searching.

    Thank you very much, David. I very much appreciate your generous effort to make this plugin useful to others. Your plugin is becoming more and more useful. Right now I am finding the enhanced search in the insert media indispensable. I do not understand why this basic ability is not included natively. I am waiting for the next version of your plugin and its continuing development. I personally prefer enhancement and compatibility to the core rather than having a separate eco-system, which can be a problem when one day the plugin becomes no more supported.

    Plugin Author David Lingren

    (@dglingren)

    I have released version 1.50, which includes the enhanced GPS support described in my earlier post to this topic.

    Thanks for your kind words and encouragement. Perhaps when I stop working so hard on the plugin I will make an effort to add some of its features to the WordPress core.

    Please let me know if you have any problems with or further questions about this new feature. Thanks again for your interest and for your suggestion.

    Thread Starter owh

    (@owh)

    Thanks a lot.

    Apparently the plugin I use seems to store the values not in custom fields. It probably has its own eco-system. I earlier mistook the available custom fields in your pulldown list as from that plugin. I am not familiar with this thing and will have to check with the author of that plugin.

    I appreciate you add the feature. Thanks again.

    Plugin Author David Lingren

    (@dglingren)

    Thanks for this update. I looked at the documentation for Fullscreen Galleria, and it looks like that plugin extracts the GPS data from the EXIF values in the image itself.

    Here are a couple of ideas to consider:

    1. You can use MLA to map the GPS data to custom fields and then use the [mla_gallery] shortcode to display the data in your gallery results. You can also map the data to the WordPress “caption” field so it is available in the standard [gallery] shortcode.
    2. You can use the “Support for Other Gallery-generating Shortcodes” feature to use [mla_gallery] for selecting the images to display, sorting them, etc. and then handing control off to [gallery] for the actual display.

    If there’s anything else I can do to help, let me know. Good luck with your application.

    Thread Starter owh

    (@owh)

    Thank you very much, David. Very much appreciate you go extra miles to help. You suggestions will come in handy when situation demand.

    I have asked the author of FSG to find out if he stores the GPS values in custom fields. I understand his plugin extract the values from the image itself during upload (so images uploaded earlier are not taken cared of), however I can’t figure out where those values are stored. It appears to store in the database (table, field thingy). I will wait for the reply from the author of FSG.

    Thread Starter owh

    (@owh)

    I have received a reply from the Fullscreen Galleria author as below:

    GPS coordinates are saved to attachment metadata in [‘image_meta’][‘longitude’] and [‘image_meta’][‘latitude’] fields.

    Is MLA able to populate above fields? I am not familiar with the terms, so am not sure if they are similar to custom fields. Thanks.

    Plugin Author David Lingren

    (@dglingren)

    The current MLA version can access anything in the “image_meta” field that WordPress creates (and Fullscreen Galleria adds to). You can find more information in the Settings/Media Library Assistant Documentation tab, “Field-level Markup Substitution Parameters” section:

    meta
    WordPress attachment metadata, if any, embedded in the image/audio/video file. For this category, you can code any of the field names embedded in the _wp_attachment_metadata array. The “Attachment Metadata” display in the Media/Edit Media screen will show you the names and values of these fields. Note that the fields available differ among image, audio and video attachments.

    You can access the values in an [mla_gallery] shortcode by coding [+meta:image_meta.longitude+] or [+meta:image_meta.latitude+]. You can also map the values to custom fields by following the instructions in the “Custom Field Processing Options” section.

    The current MLA version does not have a feature to extract the GPS information from the image and map it into the “image_meta” field. I’ve thought about adding that feature but have not started working on it.

    So, the current MLA version will let you access the data already added to “image_meta”, but will not help process the images you uploaded before installing Fullscreen Galleria. I will look at adding that to the next version or so and update this topic when I have progress to report.

    Thread Starter owh

    (@owh)

    Many thanks again, David. That will be extremely helpful. I trust the feature will only benefit others.

    Plugin Author David Lingren

    (@dglingren)

    I have released version 1.51, which adds the ability to add or change values within the image_meta field and any other elements of the _wp_attachment_metadata array as well. The example I give in the Settings/Media Library Assistant Documentation tab adds GPS information to the image_meta, so you should find it easy to apply to your site.

    I also added four more Enhanced GPS values, so the format required by the Fullscreen Galleria plugin is readily available.

    Thanks for your patience and for motivating this new feature. Please let me know if you have any problems or further questions.

    Thread Starter owh

    (@owh)

    Thanks a lot, David! It works!
    My apology to get back late as I have been busy with other things.

    I managed to update the fields in 80k+ photos within a few minutes time.

    There were a few warnings, though I am bothered, that you may be interested to know:

    Warning: exif_read_data(PC230115.jpg) [exif_read_data]: corrupt EXIF header: maximum directory nesting level reached in ***/wp/wp-content/plugins/media-library-assistant/includes/class-mla-data.php on line 4247

    Warning: exif_read_data(PD010484_reduced.jpg) [exif_read_data]: Illegal IFD size: 2 + x3E00*12 = x2E802 > x02F6 in ***/public_html/wp/wp-content/plugins/media-library-assistant/includes/class-mla-data.php on line 4247

    Thank you very much for making such a useful plugin.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Geo-tag custom field’ is closed to new replies.