aboutsummaryrefslogtreecommitdiff
path: root/image.sh
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2026-06-02 21:28:39 +0530
committerAkshay Nair <phenax5@gmail.com>2026-06-02 21:28:39 +0530
commit49bc31720ab6206980cda95a0a30a44e7f882fcc (patch)
tree9dc6540563d04dd4daceb8b716d83b15a0de89d3 /image.sh
parent4ccc095ed2efeda97805bdfb9473f62ed46220b7 (diff)
downloadsqlite-creative-coding-49bc31720ab6206980cda95a0a30a44e7f882fcc.tar.gz
sqlite-creative-coding-49bc31720ab6206980cda95a0a30a44e7f882fcc.zip
Clean up the c stuff and switch to simple bash + add example
Diffstat (limited to '')
-rwxr-xr-ximage.sh13
1 files changed, 13 insertions, 0 deletions
diff --git a/image.sh b/image.sh
new file mode 100755
index 0000000..b697688
--- /dev/null
+++ b/image.sh
@@ -0,0 +1,13 @@
+#!/usr/bin/env sh
+
+DB=fun.db
+
+[ $# -lt 1 ] && echo "Fuck" && exit 1;
+
+db() { sqlite3 -list "$DB" "$@"; }
+
+image_id="$1"
+echo "P3"
+db "SELECT width, height FROM images WHERE id=$image_id" | awk -F'|' '{ print $1 " " $2 }'
+echo "255"
+db "SELECT r,g,b FROM pixels WHERE image_id=$image_id ORDER BY y ASC, x ASC" | tr '|' ' '