useful_linux_scripts/ppt2png.sh
2024-12-10 12:37:30 +00:00

30 lines
852 B
Bash
Executable File

#!/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
gwenview image.png
rm $temp_file
################################################################################