Difference between revisions of "TruxtonFileIO newexif"

From truxwiki.com
Jump to navigation Jump to search
(Created page with "This create new EXIF record from a file in Truxton. It automatically associates the parent file and media identifiers used in the EXIF table. =Syntax= <synta...")
 
Line 1: Line 1:
This create new EXIF record from a file in Truxton.
+
This create new [https://en.wikipedia.org/wiki/Exif EXIF] record from a file in Truxton.
 
It automatically associates the parent file and media identifiers used in the [[EXIF Table | EXIF table.]]
 
It automatically associates the parent file and media identifiers used in the [[EXIF Table | EXIF table.]]
  

Revision as of 14:49, 25 May 2020

This create new EXIF record from a file in Truxton. It automatically associates the parent file and media identifiers used in the EXIF table.

Syntax

object newexif();

Return value

An EXIF object

Sample

import truxton
from datetime import datetime
from calendar import timegm

EPOCH_AS_FILETIME = 116444736000000000
HUNDREDS_OF_NANOSECONDS = 10000000

def date_to_filetime(dt):
  return EPOCH_AS_FILETIME + (timegm(dt.timetuple()) * HUNDREDS_OF_NANOSECONDS)

def main():
  t = truxton.create()
  file = t.getfileid("5ec2a123-74d6-5da7-0653-4e6800000000")

  exif = file.newexif()

  exif.gpstime = date_to_filetime(datetime.utcnow())
  exif.devicetime = date_to_filetime(datetime.utcnow())
  exif.shuttercount = 42
  exif.make = "Goosungapl"
  exif.model = "BFG-9000"
  exif.bodyserialnumber = "TX010188-PY"
  exif.latitude = 31.554759
  exif.longitude = -97.128955
  exif.altitude = 100
  exif.heading = 300
  exif.focallength = 28.2

  if exif.save() is True:
    print( "New EXIF saved as id " + exif.id)

if __name__ == "__main__":
  main()