Here's a snipet from my _flintstones_ bash script
aiming to generate an image of the number that is
the variable 'size'.
output_file="number_image.png"
# 'imagemagic convert' the number to an image
# the old 'convert' is now 'magic'
magick -pointsize 90 \
-fill "#cccccc" -background "#002200" label:"$size" "$output_file"
I use 'feh' to splash random (quiz) numbers right onto the kde desktop
but the current code does not format and I end up with unplesant
transparency holes.
I'd like to upgrade the script so as to generate image 'output_file' as
the white image of a 4 digit number with up to 3 leading zeros on a
black background, or up to 3 leading black spaces insted of zeros.
TIA
On Nov 8, 2025 at 9:09:51 AM MST, "bad sector" wrote <8R-cnUwRkr7E9pL0nZ2dnZfqn_qdnZ2d@giganews.com>:
Here's a snipet from my _flintstones_ bash script
aiming to generate an image of the number that is
the variable 'size'.
output_file="number_image.png"
# 'imagemagic convert' the number to an image
# the old 'convert' is now 'magic'
magick -pointsize 90 \
-fill "#cccccc" -background "#002200" label:"$size" "$output_file"
I use 'feh' to splash random (quiz) numbers right onto the kde desktop
but the current code does not format and I end up with unplesant
transparency holes.
I'd like to upgrade the script so as to generate image 'output_file' as
the white image of a 4 digit number with up to 3 leading zeros on a
black background, or up to 3 leading black spaces insted of zeros.
TIA
#!/bin/bash
size="$1"
output_file="number_image.png"
# Pad with zeros (or spaces)
formatted=$(printf "%04d" "$size")
# Generate the image
convert -size 300x120 \
-background black \
-fill white \
-font DejaVu-Sans-Bold \
-gravity center \
-pointsize 90 \
label:"$formatted" \
"$output_file"
-----
Saves it to your home folder. Of course you can change the path as you wish. Tested on Ubuntu and it worked.
I did use ChatGPT to help me make this... if that matters.
| Sysop: | DaiTengu |
|---|---|
| Location: | Appleton, WI |
| Users: | 1,089 |
| Nodes: | 10 (0 / 10) |
| Uptime: | 154:07:24 |
| Calls: | 13,921 |
| Calls today: | 2 |
| Files: | 187,021 |
| D/L today: |
3,791 files (953M bytes) |
| Messages: | 2,457,169 |