15 Commits

Author SHA1 Message Date
628088918b Typos. 2020-11-16 19:27:00 +01:00
e0e7dbd0e5 Removed specific Python 3 version. Ignored vscode stuff. 2020-08-03 22:40:30 +02:00
c9620394de Made Python version requirement less specific. Since I don't use any hyper-modern stuff, requiring Pyton 3.x should be sufficient. 2020-05-01 19:00:27 +02:00
67db75ece8 Fixed broken link to github help page. 2020-04-16 10:55:06 +02:00
6cab491721 Changed Issue link to gitea. 2020-04-16 10:42:20 +02:00
905ac497e1 Fixed release data in changelog. 2020-04-11 00:45:22 +02:00
07ca626ca8 Unified mentions for Exif/ITPC/XMP tags. Finalized 0.3.2 release. 2020-04-11 00:43:29 +02:00
2f94211507 Made documentation and changelog match the addition of additional ITPC/XMP tags. 2020-04-08 14:17:02 +02:00
0998371ad6 Added alternative comment fields, as Lightroom discards Exif.Photo.UserComment. 2020-04-08 13:07:15 +02:00
a9453dd51e Added 0.3.1 release to changelog. 2020-04-03 18:00:11 +02:00
98c5cad858 Added pipenv to changelog. 2020-04-03 10:46:37 +02:00
2ad17eab2a Merge branch 'master' into develop 2020-04-03 10:38:53 +02:00
b816d04215 Prepared pipenv virtual environment and added documentation. 2020-04-03 10:34:05 +02:00
58ae86db7e Added contributing guide, exchanged geigerlog main window screenshot with light colorscheme. 2020-03-27 13:21:23 +01:00
0ae188a0ec Fixed typo. 2020-03-26 20:18:37 +01:00
8 changed files with 99 additions and 19 deletions

2
.gitignore vendored
View File

@@ -2,3 +2,5 @@ testdata
testsource
testdest
__pycache__
Pipfile.lock
.vscode

View File

@@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [0.3.2] - 2020-04-11
### Added
- Added additional Exif and ITPC data fields for radiation comment.
## [0.3.1] - 2020-04-03
### Added
- Prepared pipenv virtual environment.
## [0.3] - 2020-03-23
Major rewrite following OOP style. Adds GPS/GPX handling.

34
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,34 @@
# How to contribute
I'm really glad you're reading this, if you are willing to contribute to this project in some form.
This is a quite small project with relatively low complexity so conventions are not as strict as they might be elsewhere. I am keen to learn whether and how this thing was useful to you, where you had problems and what you think could be improved.
Here are some important resources:
* This [Blogpost](https://www.commander1024.de/wordpress/2020/03/fotos-mit-daten-zu-radioaktiver-strahlung-taggen) tells you about intention and scope for this tool (in German).
* For questions and suggestions, you can [E-Mail](mailto:commander@commander1024.de) me directly.
* Bugs? [Gitlab](https://git.commander1024.de/Commander1024/radiation-tager/issues) is where to report them.
## Submitting changes
Please send a [Pull Request to radiation_tagger](https://git.commander1024.de/Commander1024/radiation-tager/pulls) in the develop branch with a clear list of what you've done (read more about [pull requests](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request)). Please follow our coding conventions (below) and make sure all of your commits are atomic (one feature per commit).
Keep in mind that I am a bloody beginner and probably make more mistakes than you, so I am always open for improvements.
Always write a clear log message for your commits. One-line messages are fine for small changes, but bigger changes should look like this:
$ git commit -m "A brief summary of the commit
>
> A paragraph describing what changed and its impact."
## Coding conventions
Start reading the code and you'll get the hang of it. We optimize for readability:
* We indent using 4 spaces (soft tabs).
* We use "describing" variables with underscores like 'position_list'.
* Classes and functions go to functions.py to keep the main program small and easy to understand.
* We generally follow the Python 3 coding style guidelines.
* This is open source software. Consider the people who will read your code, and make it look nice for them. It's sort of like driving a car: Perhaps you love doing donuts when you're alone, but with passengers the goal is to make the ride as smooth as possible.
Thanks,
Commander1024

15
Pipfile Normal file
View File

@@ -0,0 +1,15 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
pylint = "*"
[packages]
pytz = "*"
gpxpy = "*"
py3exiv2 = "*"
# [requires]
# python_version = "3.8"

View File

@@ -8,15 +8,32 @@ It can parse a .his (CSV) file from a [GeigerLog](https://sourceforge.net/projec
It can optionally read a gpx-file, compare the timestamps to 'DateTimeOriginal' and determine closest-matching latitude / longitude / altitude. Timestamps in GPX files are ususally stored in UTC timezone, you can set --timezone to match the local timezone, your camera / geiger counter ran at.
It then creates a `UserComment` with the actual measured radiation at the time the photo has been taken and writes the geocoordinates into the appropiate Exif tags.
It then creates some Exif/ITPC/XMP Comment/Description tags with the actual measured radiation at the time the photo has been taken and writes the geocoordinates into the appropiate Exif tags.
## Dependencies
Right now it depends on the following non-core Python 3 libraries:
Right now it depends on the following non-core Python 3 libraries. These can be installed using the package manager of your distribution.
* [py3exiv2](https://pypi.org/project/py3exiv2/) A Python 3 binding for (lib)exiv2.
* [boost.python3](http://www.boost.org/libs/python/doc/index.html) Welcome to Boost.Python, a C++ library which enables seamless interoperability between C++ and the Python programming language.
* [exiv2](http://www.exiv2.org/) Exiv2 is a Cross-platform C++ library and a command line utility to manage image metadata.
* [gpxpy](https://github.com/tkrajina/gpxpy) gpx-py is a python GPX parser. GPX (GPS eXchange Format) is an XML based file format for GPS tracks.
* [pytz](https://pypi.org/project/pytz/) World timezone definitions, modern and historical.
* [gpxpy](https://pypi.org/project/gpxpy/) gpx-py is a python GPX parser. GPX (GPS eXchange Format) is an XML based file format for GPS tracks.
### Setting up a virtual environment using pipenv
If you prefer to use more updated versions of the dependencies or you do not want to use Python dependencies into your system, I prepared a pipenv virtual environment for you.
Using `pipenv install` all dependencies will be installed automatically. With `pipenv shell` you can source the venv.
For py3exivv2 to work / compile the following dependencies must be installed - preferably from your system's package manager:
* [exiv2](http://www.exiv2.org/) and it's development package. Exiv2 is a Cross-platform C++ library and a command line utility to manage image metadata.
* [boost](https://www.boost.org/) and it's development package. Boost provides free peer-reviewed portable C++ source libraries.
* [boost.python3](http://www.boost.org/libs/python/doc/index.html) and it's development package. A C++ library which enables seamless interoperability between C++ and the Python programming language.
#### Debian / Ubuntu
sudo apt install pipenv build-essential python-all-dev libexiv2-dev libboost-python-dev
#### Fedora
sudo dnf install pipenv exiv2-devel boost-devel boost-python3-devel make automake gcc gcc-c++
## Requirements
* A bunch of images (jpg, cr2, etc.) with its time of creation stored in `DateTimeOriginal`.
@@ -39,7 +56,7 @@ usage: rad_tag.py [-h] [-si SIFACTOR] [-tz Timezone] [-d] [-g GPX] [-o OUTDIR]
CSV Photo [Photo ...]
A unix-tyle tool that extracts GPS and/or radiation data from GPX/CSV files
and writes them into the Exif tags of given photos.
and writes them into the Exif/ITPC/XMP tags of given photos.
positional arguments:
CSV Geiger counter history file in CSV format.
@@ -127,7 +144,7 @@ Once imported, you can export the history into a hisdb.his-file, which is basica
## GPS setup
Especially if you use a mobile phone for GPS-logging. Take care, the app can use GPS when turned off, and let it write position sufficiently often. Threshold is 5 minutes by default, but precision will improve when logging more often. Especially "inactivity detection" might become a problem, when staying at one place for a period of time.
Especially if you use a mobile phone for GPS-logging, ensure the app can use GPS when the phone is locked. Let it write position sufficiently often. Threshold is 5 minutes by default, but precision will improve when logging more often. Especially "inactivity detection" might become a problem, when staying at one place for a period of time.
## future possibilities

View File

@@ -11,12 +11,12 @@ import pyexiv2
class Radiation:
'''
Reiceives values vom CSV file and creates a list of the relevant data
Receives values vom CSV file and creates a list of the relevant data
Arguments:
timestamp: Date/time string from CSV as string
radiation: Radiation from CSV in CP/M as float
local_timezone: timezone for timezone-unware CSV / Photo, if GPX is timezone aware
local_timezone: timezone for timezone-unaware CSV / Photo, if GPX is timezone aware
si_factor: CP/M to (µS/h) conversion factor - specific to GMC-tube
Returns:
@@ -48,9 +48,9 @@ class Photo:
Arguments:
photo: source photo ()
local_timezone: timezone for timezone-unware CSV / Photo, if GPX is timezone aware
local_timezone: timezone for timezone-unaware CSV / Photo, if GPX is timezone aware
dest_dir: destination directory where the photo is going to be copied to.
dry_run: whether to acutally write (True / False)
dry_run: whether to actually write (True / False)
Returns:
get_date: timestamp of photo als datetime object
@@ -171,7 +171,7 @@ class Match:
class Exif:
'''
Converts, compiles and writes Exif-Tags from given arguemnts.
Converts, compiles and writes Exif/ITPC/XMP-Tags from given arguments.
Arguments:
photo: file name of photo to modify
@@ -179,7 +179,7 @@ class Exif:
latitude: latitude as float
longitude: longitude as float
elevation: elevation as float
dry_run: whether to acutally write (True / False)
dry_run: whether to actually write (True / False)
Returns:
Latitude / Longitude: in degrees
@@ -243,7 +243,11 @@ class Exif:
if radiation:
# Set new UserComment
new_comment = 'Radiation ☢ : %s µS/h' % str(round(radiation, 2))
metadata['Exif.Photo.UserComment'] = new_comment
metadata['Exif.Image.ImageDescription'] = new_comment
metadata['Iptc.Application2.Caption'] = [new_comment]
metadata['Xmp.dc.description'] = new_comment
else:
new_comment = None
@@ -294,4 +298,3 @@ class Output:
# Return data string
return data

Binary file not shown.

Before

Width:  |  Height:  |  Size: 186 KiB

After

Width:  |  Height:  |  Size: 199 KiB

View File

@@ -2,9 +2,8 @@
# -*- coding: utf-8 -*-
''' Iterates over a bunch of .jpg or .cr2 files and matches
DateTimeOriginal from Exif tag to DateTime in a csv log
of a GeigerMuellerCounter and writes its value to the UserComment
Exif tag in µS/h '''
DateTimeOriginal from Exif tags to DateTime in a csv log
of a GeigerMuellerCounter and writes its value to Exif/ITPC/XMP tags in µS/h '''
import csv
import argparse
@@ -25,7 +24,7 @@ from functions import Radiation, Photo, Match, Exif, Output
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter,
description='''A unix-tyle tool that
extracts GPS and/or radiation data from GPX/CSV files and writes
them into the Exif tags of given photos.''')
them into the Exif/ITPC/XMP tags of given photos.''')
parser.add_argument('-si', '--sifactor', type=float, default=0.0065,
help='Factor to multiply recorded CPM with.')
parser.add_argument('-tz', '--timezone', type=str, metavar='Timezone', default='utc',
@@ -57,7 +56,7 @@ with open(args.csv, "r") as f:
csv = csv.reader(filter(lambda row: row[0] != '#', f),
delimiter=',', skipinitialspace=True)
# Import only relevant values, thats timestamp and CP/M
# Import only relevant values, that's timestamp and CP/M
for _, csv_raw_time, csv_raw_cpm, _ in csv:
radiation = Radiation(csv_raw_time, csv_raw_cpm, local_timezone, args.sifactor)
radiation_list.append(radiation)