commit: 6e77751fc9d5bf7ae7b50860c2f0025453621956
parent: 1893326e2e091d17516dc7caf80f8864b65969ce
author: Chris Noxz <chris@noxz.tech>
date: Tue, 5 Dec 2023 20:00:26 +0100
allow comments in extract.dat...
...and add borders/padding to images
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/extract.sh b/extract.sh
@@ -47,7 +47,7 @@ CREATE TABLE image(
);'
# loop through data lines
-while read -r line; do
+sed -e '/^#/d' -e '/^[[:space:]]*$/d' < extract.dat | while read -r line; do
taskid=$((taskid+1))
# extract data from line
url="${line%%|*}"; line="${line#*|}"
@@ -63,6 +63,8 @@ while read -r line; do
# download pdf if not existing
[ ! -f "${pdfpath}" ] && curl -s "${url}" -o "${pdfpath}"
+ >&2 printf 'processing %s-%s: %s\n' "${course}" "${semester}" "${task}"
+
i=-1; while true; do
i=$((i+1))
@@ -73,6 +75,8 @@ while read -r line; do
pngname="$(echo "${pdfname}.${cropbox}" | md5sum | cut -d' ' -f1).png"
pngpath="${cachedir}"/"${pngname}"
+ >&2 printf ' image: %s\n' "$((i+1))"
+
# insert task into database
if [ "${i}" -eq 0 ]; then
sqlite3 "${dbpath}" "
@@ -113,6 +117,8 @@ while read -r line; do
-resize 100% \
-flatten \
-crop "${cropbox}" \
+ -bordercolor white \
+ -border 0x20 \
"${pngpath}"
# insert images into database
@@ -132,4 +138,4 @@ while read -r line; do
line="${line#*|}"
done
-done < "${datpath}"
+done