| 1 |
#!@SHELL@ |
| 2 |
|
| 3 |
# Compare ESC/P2 Raster files' dot positions to determine amount of error. |
| 4 |
# |
| 5 |
# Copyright 2016 Robert Krawitz ([email protected]) |
| 6 |
# |
| 7 |
# This program is free software; you can redistribute it and/or modify it |
| 8 |
# under the terms of the GNU General Public License as published by the Free |
| 9 |
# Software Foundation; either version 2 of the License, or (at your option) |
| 10 |
# any later version. |
| 11 |
# |
| 12 |
# This program is distributed in the hope that it will be useful, but |
| 13 |
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 14 |
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 15 |
# for more details. |
| 16 |
# |
| 17 |
# You should have received a copy of the GNU General Public License |
| 18 |
# along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 19 |
|
| 20 |
old=$1 |
| 21 |
new=$2 |
| 22 |
|
| 23 |
if [ -z "$old" ] || [ -z "$new" ] || [ ! -d "$old" ] || [ ! -d "$new" ] ; then |
| 24 |
echo "Usage: $0 dir1 dir2" |
| 25 |
exit 1 |
| 26 |
fi |
| 27 |
|
| 28 |
#files=$(ls $old | grep '\.prn$' |grep -v 'DitherAlgorithm_\(Predithered\|VeryFast\)') |
| 29 |
files=$(cat |grep 'DitherAlgorithm_Ordered_') |
| 30 |
|
| 31 |
for x in $files ; do |
| 32 |
f="$old/$x.prn" |
| 33 |
g="$new/$x.prn" |
| 34 |
if [ -f "$f" ] && [ -f "$g" ] ; then |
| 35 |
cmp -s "$f" "$g" || ( |
| 36 |
rm -f old.pnm new.pnm |
| 37 |
../../test/unprint "$f" > old.pnm 2>/dev/null |
| 38 |
../../test/unprint "$g" > new.pnm 2>/dev/null |
| 39 |
# change=$(compare -metric ae old.pnm new.pnm /dev/null 2>&1) |
| 40 |
# echo "$change | " $(perl -e "print $change") "|" |
| 41 |
change=$(perl -e "print $(compare -metric ae old.pnm new.pnm /dev/null 2>&1)") |
| 42 |
size=$(($(head -2 old.pnm |tail -1 |sed 's/ /*/'))) |
| 43 |
pct=$(perl -e "printf('%0.4f%%', 100*$change/$size)") |
| 44 |
error=$(((32768+(65536*change))/size)) |
| 45 |
printf '%10s %10s %8s %5s %s\n' "$change" "$size" "$pct" "$error" "$x" |
| 46 |
) |
| 47 |
fi |
| 48 |
done |