Skip to content
Snippets Groups Projects
Commit 6968e9d6 authored by Rolf Niepraschk's avatar Rolf Niepraschk
Browse files

läuft

parent 275cb26a
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
#
# Rolf Niepraschk <Rolf.Niepraschk@ptb.de>, 2017-03-31
#
# Erzeugt aus einem leeren Messgeräte-Bild und neun 7-Segment-Bildern
# neue Messgeräte-Bilder mit zufälliger Anzeige
#
# Parameter=Anzahl der Mantissenziffern
# (wenn angegeben, dann kein Exponenent)
MAIN="F250" # device name
IMAGE_DIR=./images
MAX_FILES=10
MAX_DIGITS=5 # do not edit!
if [ -n "$1" ]; then
NUMBER_OF_DIGITS=$1
SHOW_EXP=0
else
NUMBER_OF_DIGITS=$MAX_DIGITS
SHOW_EXP=1
fi
if (( $NUMBER_OF_DIGITS > $MAX_DIGITS )); then
NUMBER_OF_DIGITS=$MAX_DIGITS
else
if (( $NUMBER_OF_DIGITS < 1 )); then
NUMBER_OF_DIGITS=1
fi
fi
rm -rf "$IMAGE_DIR"
mkdir -p "$IMAGE_DIR"
emptyCanvas='xc:transparent'
digitFile[0]='digit-0.png'
digitFile[1]='digit-1.png'
digitFile[2]='digit-2.png'
digitFile[3]='digit-3.png'
digitFile[4]='digit-4.png'
digitFile[5]='digit-5.png'
digitFile[6]='digit-6.png'
digitFile[7]='digit-7.png'
digitFile[8]='digit-8.png'
digitFile[9]='digit-9.png'
digitFile[99]=$emptyCanvas # empty canvas
dotFile='dot.png'
minusFile='minus.png'
signPos='+156+198'
digitPos[5]='+197+198'
digitPos[4]='+238+198'
digitPos[3]='+279+198'
digitPos[2]='+320+198'
digitPos[1]='+361+198'
dotPos[5]=${digitPos[5]}
dotPos[4]=${digitPos[4]}
dotPos[3]=${digitPos[3]}
dotPos[2]=${digitPos[2]}
dotPos[1]=${digitPos[1]}
for ((FNb=1; FNb<=MAX_FILES; FNb++)); do
i=$((RANDOM % 2)) # random (0|1=''|-)
if [ $i == 0 ]; then
signFile=$emptyCanvas
SIGN=''
else
signFile=$minusFile
SIGN='-'
fi
DPR=$((RANDOM % $NUMBER_OF_DIGITS + 1)) # random dot position (1..$NUMBER_OF_DIGITS)
for (( i=1; i<=$MAX_DIGITS; i++ )); do
DNR[$i]=$((RANDOM % 10)) # random digit number (0..9)
if [ $DPR == $i ]; then
dotFile[$i]="$dotFile"
DOT[$i]="." # dot character
else
dotFile[$i]=$emptyCanvas
DOT[$i]=""
fi
done
value="$SIGN"
for (( i=1; i<=$MAX_DIGITS; i++ )); do
if (( $i <= $NUMBER_OF_DIGITS )); then
eval DIGIT$i=${digitFile[ ${DNR[i]} ]}
eval DF$i=${dotFile[i]}
value+="${DNR[i]}${DOT[i]}"
else
eval DIGIT$i=$emptyCanvas;
eval DF$i=$emptyCanvas;
fi
done
fname="$IMAGE_DIR/$MAIN@$value@.png"
convert body.png \
${signFile} -geometry ${signPos} -composite \
$DIGIT1 -geometry ${digitPos[5]} -composite \
$DF1 -geometry ${dotPos[5]} -composite \
$DIGIT2 -geometry ${digitPos[4]} -composite \
$DF2 -geometry ${dotPos[4]} -composite \
$DIGIT3 -geometry ${digitPos[3]} -composite \
$DF3 -geometry ${dotPos[3]} -composite \
$DIGIT4 -geometry ${digitPos[2]} -composite \
$DF4 -geometry ${dotPos[2]} -composite \
$DIGIT5 -geometry ${digitPos[1]} -composite \
$DF5 -geometry ${dotPos[1]} -composite \
$fname
exiv2 -M"set Exif.Image.ImageDescription value=$value" $fname
echo -e "$FNb:\t$fname"
done # MAX_FILES
exit
-----------------------------------------------------------------------
Auslesen der Exif-Daten:
exiv2 -g Exif.Image.ImageDescription -P v ./images/151.108@GERAET_X.png
--> value=151.108
exit
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment