Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is an example how to set GPS position using pyexiv2 library. I've tested this script by uploading geotagged image to Panoramio</p> <pre><code>#!/usr/bin/env python import pyexiv2 import fractions from PIL import Image from PIL.ExifTags import TAGS import sys def to_deg(value, loc): if value &lt; 0: loc_value = loc[0] elif value &gt; 0: loc_value = loc[1] else: loc_value = "" abs_value = abs(value) deg = int(abs_value) t1 = (abs_value-deg)*60 min = int(t1) sec = round((t1 - min)* 60, 5) return (deg, min, sec, loc_value) def set_gps_location(file_name, lat, lng): """Adds GPS position as EXIF metadata Keyword arguments: file_name -- image file lat -- latitude (as float) lng -- longitude (as float) """ lat_deg = to_deg(lat, ["S", "N"]) lng_deg = to_deg(lng, ["W", "E"]) print lat_deg print lng_deg # convert decimal coordinates into degrees, munutes and seconds exiv_lat = (pyexiv2.Rational(lat_deg[0]*60+lat_deg[1],60),pyexiv2.Rational(lat_deg[2]*100,6000), pyexiv2.Rational(0, 1)) exiv_lng = (pyexiv2.Rational(lng_deg[0]*60+lng_deg[1],60),pyexiv2.Rational(lng_deg[2]*100,6000), pyexiv2.Rational(0, 1)) exiv_image = pyexiv2.Image(file_name) exiv_image.readMetadata() exif_keys = exiv_image.exifKeys() exiv_image["Exif.GPSInfo.GPSLatitude"] = exiv_lat exiv_image["Exif.GPSInfo.GPSLatitudeRef"] = lat_deg[3] exiv_image["Exif.GPSInfo.GPSLongitude"] = exiv_lng exiv_image["Exif.GPSInfo.GPSLongitudeRef"] = lng_deg[3] exiv_image["Exif.Image.GPSTag"] = 654 exiv_image["Exif.GPSInfo.GPSMapDatum"] = "WGS-84" exiv_image["Exif.GPSInfo.GPSVersionID"] = '2 0 0 0' exiv_image.writeMetadata() set_gps_location(sys.argv[1], float(sys.argv[2]), float(sys.argv[3])) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload