diff --git a/.gitignore b/.gitignore index e0a2c45..29e5a26 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ penny_dreadful_downloader/legality_data/ a_scanner_dorkly/.venv/ +scantap/images/ MTG-Card-Identifier_v5.pdf info.txt diff --git a/scantap/createtable.sql b/scantap/createtable.sql new file mode 100644 index 0000000..701d209 --- /dev/null +++ b/scantap/createtable.sql @@ -0,0 +1,8 @@ +USE sevenkeys; + +CREATE TABLE IF NOT EXISTS CardScans ( + Id INT PRIMARY KEY AUTO_INCREMENT, + StorageBox VARCHAR(20) NOT NULL, + Position INT NOT NULL, + Source VARCHAR(100) NULL +); diff --git a/scantap/scantap.sh b/scantap/scantap.sh new file mode 100755 index 0000000..cc2418f --- /dev/null +++ b/scantap/scantap.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +mysql --user=root --password="$(pass show sevenkeys/mysql)" /dev/null + + # scanimage exits with code 7 if no documents are available in scanner + if test $? -eq 7; then + if test $ADD_CARDS -eq 0; then + ADD_CARDS=1 + echo "scantap: No more cards in feeder" >&2 + fi + + continue + fi + ADD_CARDS=0 + + if ! test -e tmp1.png || ! test -e tmp2.png; then + echo "scantap: Failed to create temporary image files" + fi + + key="$(mysql --silent --silent --user=root --password="$(pass show sevenkeys/mysql)" -e "USE sevenkeys; INSERT INTO CardScans (StorageBox, Position, Source) VALUES ('$storageBox', '$position', '$cardSource'); SELECT Id FROM CardScans ORDER BY Id DESC LIMIT 1;")" + position=$((position + 1)) + + convert -rotate 180 tmp1.png tmp1.png + convert -rotate 180 tmp2.png tmp2.png + + mv tmp1.png "$outputDir/${key}_back.png" + mv tmp2.png "$outputDir/${key}_front.png" +done