From e5861f70e1460123d858d71312f8697947a082c6 Mon Sep 17 00:00:00 2001 From: Robin Clark Date: Thu, 5 Dec 2024 13:56:32 +0000 Subject: [PATCH] paper tape to png image file --- ppt2png.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 ppt2png.sh diff --git a/ppt2png.sh b/ppt2png.sh new file mode 100644 index 0000000..e5510f2 --- /dev/null +++ b/ppt2png.sh @@ -0,0 +1,28 @@ +#!/usr/bin/bash +################################################################################ +# Generate temporary file safely +temp_file=$(mktemp) +ppt "$1" > "$temp_file" + +# Count lines directly +line_count=$(wc -l < "$temp_file") + +# Calculate image height (e.g., 20 pixels per line, with a minimum height) +line_height=20 +image_height=$((line_count * line_height)) +[ "$image_height" -lt 70 ] && image_height=70 # Ensure a minimum height of 70 pixels + +# Generate image with dynamic height and fixed-width font +convert \ + -size 165x${image_height} \ + xc:lightblue \ + -font Courier \ + -pointsize 12 \ + -fill blue \ + -gravity center \ + -draw "text 0,0 '$(cat "$temp_file")'" \ + image.png + +# Clean up temporary file +rm $temp_file +################################################################################