Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
venv/
16 changes: 11 additions & 5 deletions paperbackup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import sys
import hashlib
import subprocess
import qrencode
import qrcode
from tempfile import mkstemp
from datetime import datetime
from PIL import Image
Expand All @@ -57,10 +57,16 @@


def create_barcode(chunkdata):
version, size, im = qrencode.encode(chunkdata,
level=qrencode.QR_ECLEVEL_H,
case_sensitive=True)
return im
qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_Q,
box_size=10,
border=4,
)
qr.add_data(chunkdata)
qr.make(fit=True)
img = qr.make_image(fill_color="black", back_color="white")
return img


def finish_page(pdf, canv, pageno):
Expand Down
8 changes: 4 additions & 4 deletions paperrestore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ if [ -z "$SCANNEDFILE" ]; then
exit 1
fi

if ! [ -f "$SCANNEDFILE" ]; then
if [ ! -f "$SCANNEDFILE" ]; then
echo "$SCANNEDFILE is not a file"
exit 1
fi

if [ ! -x "/usr/bin/zbarimg" ]; then
echo "/usr/bin/zbarimg missing"
if [ ! -x "$(command -v zbarimg)" ]; then
echo "zbarimg missing"
exit 2
fi

Expand All @@ -27,7 +27,7 @@ fi
# so convert that to \0<number><space>, so sort can sort on that
# then remove all \n\0<number><space> so we get the originial without newlines added

/usr/bin/zbarimg --raw -Sdisable -Sqrcode.enable "$SCANNEDFILE" \
zbarimg --raw -Sdisable -Sqrcode.enable "$SCANNEDFILE" \
| sed -e "s/\^/\x0/g" \
| sort -z -n \
| sed ':a;N;$!ba;s/\n\x0[0-9]* //g;s/\x0[0-9]* //g;s/\n\x0//g'