Difference between revisions of "TruxtonFileIO newexif"
Jump to navigation
Jump to search
(→Sample) |
|||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
This create new [https://en.wikipedia.org/wiki/Exif 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 <code><nowiki>[</nowiki>[[EXIF Table|EXIF]]<nowiki>]</nowiki></code> table. |
=Syntax= | =Syntax= | ||
| − | < | + | <source lang="Python"> |
object newexif(); | object newexif(); | ||
| − | </ | + | </source> |
=Return value= | =Return value= | ||
| − | An EXIF object | + | An [[TruxtonEXIF|EXIF]] object |
=Sample= | =Sample= | ||
| − | + | <source lang="Python" highlight="15"> | |
| − | < | ||
import truxton | import truxton | ||
from datetime import datetime | from datetime import datetime | ||
| Line 45: | Line 44: | ||
if __name__ == "__main__": | if __name__ == "__main__": | ||
| − | main() | + | sys.exit(main()) |
| − | </ | + | </source> |
Latest revision as of 10:04, 3 February 2024
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__":
sys.exit(main())