useful_linux_scripts/ppt_to_png.sh

29 lines
677 B
Bash
Raw Permalink Normal View History

2025-01-21 10:26:09 +00:00
#!/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:lightyellow \
-font Courier \
-pointsize 12 \
-fill blue \
-gravity center \
-draw "text 0,0 '$(cat "$temp_file")'" \
image.png
# Clean up temporary file
rm "$temp_file"