#!/bin/sh
# Schreibt EXIF-Daten in ein JPEG-Bild (Autor, Lizenz, Beschreibung)

ARTIST="my name"        # Hier den eigenen Namen eintragen!
COPYRIGHT="This work is licensed under the Creative Commons Attribution 3.0 Germany License."
LICENSELINK="http://creativecommons.org/licenses/by/3.0/de/"

# Lizenz auswählen
LICENSE=`zenity --list --width=650 --height=350 --title="Lizenz auswählen" --text="Wählen Sie eine der folgenden Lizenzen aus." --radiolist --column="" --column Punkt --column Beschreibung \
\"\" CC-0		"Zero (gemeinfrei)" \
\"\" CC-BY		"Namensnennung" \
TRUE CC-BY-SA		"Namensnennung, Weitergabe unter gleichen Bedingungen" \
\"\" CC-BY-ND		"Namensnennung, keine Bearbeitung" \
\"\" CC-BY-NC		"Namensnennung, nicht komerziell" \
\"\" CC-BY-NC-SA	"Namensnennung, nicht komerziell, Weitergabe unter gleichen Bedingungen" \
\"\" CC-BY-NC-ND	"Namensnennung, nicht komerziell, keine Bearbeitung" \
\"\" Copyright		"Alle Rechte vorbehalten" \
`

if [ -z "$LICENSE" ];then
        exit 1
elif [ "$LICENSE" = CC-0 ];then
        COPYRIGHT="No copyright. The autor released this work to public domain."
	LICENSELINK="http://creativecommons.org/publicdomain/zero/1.0/deed.de"
elif [ "$LICENSE" = CC-BY ];then
        COPYRIGHT="This work is licensed under the Creative Commons Attribution 3.0 Germany License."
	LICENSELINK="http://creativecommons.org/licenses/by/3.0/de/"
elif [ "$LICENSE" = CC-BY-SA ];then
        COPYRIGHT="This work is licensed under the Creative Commons Attribution - Share Alike 3.0 Germany License."
	LICENSELINK="http://creativecommons.org/licenses/by-sa/3.0/de/"
elif [ "$LICENSE" = CC-BY-ND ];then
        COPYRIGHT="This work is licensed under the Creative Commons Attribution - No Derivative Works 3.0 Germany License."
	LICENSELINK="http://creativecommons.org/licenses/by-nd/3.0/de/"
elif [ "$LICENSE" = CC-BY-NC ];then
        COPYRIGHT="This work is licensed under the Creative Commons Attribution - Noncommercial 3.0 Germany License."
	LICENSELINK="http://creativecommons.org/licenses/by-nc/3.0/de/"
elif [ "$LICENSE" = CC-BY-NC-SA ];then
        COPYRIGHT="This work is licensed under the Creative Commons Attribution - Noncommercial - Share Alike 3.0 Germany License."
	LICENSELINK="http://creativecommons.org/licenses/by-nc-sa/3.0/de/"
elif [ "$LICENSE" = CC-BY-NC-ND ];then
        COPYRIGHT="This work is licensed under the Creative Commons Attribution - Noncommercial - No Derivative Works 3.0 Germany License."
	LICENSELINK="http://creativecommons.org/licenses/by-nc-nd/3.0/de/"
elif [ "$LICENSE" = Copyright ];then
        COPYRIGHT="All rights reserved by the author of this work."
	LICENSELINK="You have to ask the author for permission."
fi

# Beschreibung auswählen
IMAGE_DESCRIPTION=`zenity --entry --width=500 --title="JPEG Kommentar hinzufügen" --text="Geben Sie eine Beschreibung ein."`

if [ -z "$IMAGE_DESCRIPTION" ];then
        exit 1
fi

# EXIF-Daten schreiben
for FROM in $@
do
        EXIT_INFO=`exiftool -overwrite_original -ImageDescription="$IMAGE_DESCRIPTION" -Artist="$ARTIST" -Copyright="$COPYRIGHT" -XMP-cc:License="$LICENSELINK" $FROM`
        if [ "$EXIT_INFO" -ne "1" ]; then
                zenity --warning --text="Exiftool beendet mit $EXIT_INFO. Ist ein Fehler aufgetreten?"
        fi
done
