This repository was archived by the owner on Nov 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·51 lines (44 loc) · 1.36 KB
/
entrypoint.sh
File metadata and controls
executable file
·51 lines (44 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env bash
IMAGE_FORAMT="png"
HIGHLIGHT_COLOUR="red"
while [[ $# -gt 1 ]]; do
case $1 in
-f|--format)
IMAGE_FORAMT="$2"
shift
;;
*)
;;
esac
shift
done
function run(){
rm -rf /result/*
echo "results:" > /result/results.yaml
find /base -type f -name "*.${IMAGE_FORAMT}" | while read BASE_IMAGE_PATH; do
IMAGE_RELATIVE_PATH="${BASE_IMAGE_PATH#"/base/"}"
COMPARE_IMAGE_PATH="/compare/${IMAGE_RELATIVE_PATH}"
RESULT_IMAGE_PATH="/result/${IMAGE_RELATIVE_PATH}"
if [ -f /compare/${IMAGE_RELATIVE_PATH} ]; then
mkdir -p $(dirname ${RESULT_IMAGE_PATH})
compare -metric 'RMSE' -highlight-color ${HIGHLIGHT_COLOUR} \
${BASE_IMAGE_PATH} ${COMPARE_IMAGE_PATH} ${RESULT_IMAGE_PATH} >${RESULT_IMAGE_PATH}_.txt 2>&1
RMS=$(cat ${RESULT_IMAGE_PATH}_.txt | awk -F'[)(]' '{print $2}')
PASS=$(awk "BEGIN { pass=${RMS}==0; print pass }")
if [ ${PASS} == "1" ]; then
rm -f ${RESULT_IMAGE_PATH} ${RESULT_IMAGE_PATH}_.txt
writeResult ${IMAGE_RELATIVE_PATH} true
echo "${IMAGE_RELATIVE_PATH} :: PASS"
else
writeResult ${IMAGE_RELATIVE_PATH} false
convert -delay 50 ${BASE_IMAGE_PATH} ${RESULT_IMAGE_PATH} -loop 0 ${RESULT_IMAGE_PATH}_.gif
echo "${IMAGE_RELATIVE_PATH} :: FAIL"
fi
fi
done
}
function writeResult(){
echo " - image: ${1}" >> /result/results.yaml
echo " pass: ${2}" >> /result/results.yaml
}
run