Use 8bit and fix glitch in qr decoding

This commit is contained in:
Alisina Bahadori
2020-09-04 15:07:12 +04:30
parent 1927a3d60e
commit 949e7be929
4 changed files with 16 additions and 15 deletions

1
.gitignore vendored
View File

@@ -1 +1,2 @@
*.tar
*.tgz

View File

@@ -14,12 +14,12 @@ do
noext=${f%.*}
chunk=$(echo $noext |rev | cut -f 1 -d '-' | rev)
zbarimg --raw --quiet --oneshot $f > "$chunk-$noext.chunk"
zbarimg --raw -Sbinary --quiet --oneshot $f | head -c 2953 > "$chunk-$noext.chunk"
done
cd $cur
ls $dir/*.chunk | sort | xargs cat | base64 -d | xz -dc > $outputfile
echo "$(ls $dir/*.chunk | sort)"
ls $dir/*.chunk | sort | xargs cat > $outputfile
rm $dir/*.chunk
echo "File reconstructed as $outputfile please check the bellow sha1 with the sha1 of the file in your media."

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

After

Width:  |  Height:  |  Size: 103 KiB

View File

@@ -1,25 +1,24 @@
#!/bin/sh -e
while getopts "xz:" opt; do
while getopts "c:" opt; do
case $opt in
x) xz=true ;;
z) gz=true ;;
\?) echo -e "\t -x: Use xz to compress\n\t -z Use gz to compress"; exit ;;
c) comment=$OPTARG ;; # Handle -c
\?) echo "Use -c \"COMMENT\" to add comment to images."; exit ;; # Handle error: unknown option or missing required argument.
esac
done
file="$1"
prefix="$1-"
dir="$file-qr"
for file in $@; do :; done
filename=$(echo $file | rev | cut -f 1 -d '/' | rev)
prefix="$filename-"
dir="$filename-qr"
mkdir -p $dir
rm -f $dir/*
sha=$(sha1sum $file | cut -f 1 -d ' ')
date=$(date -u)
date=$(date -u --iso-8601=seconds)
cat $file | xz -z | base64 -w0 | split -d -C 2920 -a3 - "$dir/$prefix"
cat $file | split -d -b 2953 -a3 - "$dir/$prefix"
cd $dir
@@ -31,11 +30,12 @@ do
chunksha=$(sha1sum $f | cut -f 1 -d ' ')
out="$f.png"
cat $f | qrencode --size=13 --margin=1 --output "$out"
cat $f | qrencode --8bit -v 40 --size=13 --margin=1 --output "$out"
convert -size 2490x3510 xc:white \( $out -gravity center \) -composite \
-pointsize 72 -gravity northwest -annotate +100+200 "FILE: $file\n\nCHUNK: $f\n\nTOTAL CHUNKS: $count" \
-gravity southwest -pointsize 41 -annotate +100+300 "CHUNK ${f##*-} SHA1: $chunksha\n\nFINAL SHA1: $sha" \
-gravity northeast -pointsize 41 -annotate +100+200 "$date" \
-gravity northeast -pointsize 41 -annotate +100+130 "$date" \
-gravity southeast -pointsize 41 -annotate +100+150 "$comment" \
-gravity southwest -pointsize 41 -annotate +100+150 "gitlab.com/alisinabh/paperify" $out
rm $f