Compare commits

...

12 Commits
0.3 ... main

8 changed files with 92 additions and 13 deletions

1
.gitignore vendored
View File

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

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

14
Pipfile Normal file
View File

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

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

@ -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
@ -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

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)