Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 53 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,54 @@
*.pyc
build
dist
MANIFEST
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/
52 changes: 50 additions & 2 deletions pexif.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,31 @@ class IfdGPS(IfdData):
0x3: ("East or West Longitude", "GPSLongitudeRef", ASCII, 2),
0x4: ("Longitude", "GPSLongitude", RATIONAL, 3),
0x5: ("Altitude reference", "GPSAltitudeRef", BYTE, 1),
0x6: ("Altitude", "GPSAltitude", RATIONAL, 1)
0x6: ("Altitude", "GPSAltitude", RATIONAL, 1),
0x7: ("UTC (Coordinated Universal Time)", "GPSTimeStamp", RATIONAL, 3),
0x8: ("Satellites", "GPSSatellites", ASCII),
0x9: ("Status", "GPSStatus", ASCII, 2),
0xA: ("Measure Mode", "GPSMeasureMode", ASCII, 2),
0xB: ("DOP (Data Degree of Precision)", "GPSDOP", RATIONAL, 1),
0xC: ("Speed: [K]ilometers, [M]iles or [K]nots", "GPSSpeedRef", ASCII, 2),
0xD: ("Speed", "GPSSpeed", RATIONAL, 1),
0xE: ("Track Direction: [T]rue or [M]agnetic", "GPSTrackRef", ASCII, 2),
0xF: ("Track Direction: (0.00 to 359.99)", "GPSTrack", RATIONAL, 1),
0x10: ("Image Direction: [T]rue or [M]agnetic", "GPSImgDirectionRef", ASCII, 2),
0x11: ("Image Direction: (0.00 to 359.99)", "GPSImgDirection", RATIONAL, 1),
0x12: ("Datum: WGS-84", "GPSMapDatum", ASCII),
## 13 MISSING
## 14 MISSING
## 15 MISSING
## 16 MISSING
0x17: ("Destination Bearing: [T]rue or [M]agnetic", "GPSDestBearingRef", ASCII, 2),
0x18: ("Destination Bearing: (0.00 to 359.99)", "GPSDestBearing", RATIONAL, 1),
## 19 MISSING
## 1A MISSING
## 1B MISSING
## 1C MISSING
## 1D MISSING
## 1E MISSING
}

def __init__(self, e, offset, exif_file, mode, data=None):
Expand Down Expand Up @@ -1205,12 +1229,36 @@ def _parse(val):

_parse = staticmethod(_parse)

def set_geo(self, lat, lng):
def set_altitude(self, elevation):
"""Set the elevation"""

gps = self.exif.primary.GPS
gps.GPSAltitude = [Rational(elevation, 1)]
gps.GPSAltitudeRef = '0' if elevation >= 0 else '1'

def set_direction(self, direction, ref='T'):
"""Set the image direction"""

gps = self.exif.primary.GPS
gps.GPSImgDirection = [Rational(direction, 1)]
gps.GPSImgDirectionRef = ref

def set_bearing(self, bearing, ref='T'):
"""Set the image bearing"""

gps = self.exif.primary.GPS
gps.GPSDestBearing = [Rational(bearing, 1)]
gps.GPSDestBearingRef = ref

def set_geo(self, lat, lng, datum='WGS-84'):
"""Set the GeoLocation to a given lat and lng"""

if self.mode != "rw":
raise RWError

gps = self.exif.primary.GPS
gps.GPSMapDatum = datum
gps.GPSVersionID = '2 0 0 0'

sign, deg, min, sec = JpegFile._parse(lat)
ref = "N"
Expand Down