paper tape to png image file
This commit is contained in:
parent
ecd436f926
commit
e5861f70e1
28
ppt2png.sh
Normal file
28
ppt2png.sh
Normal file
@ -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
|
||||
################################################################################
|
Loading…
Reference in New Issue
Block a user