33 lines
3.3 KiB
Bash
33 lines
3.3 KiB
Bash
|
#!/bin/bash
|
||
|
|
||
|
if [ -z "$1" ]; then
|
||
|
echo "Usage: $0 <text_string>"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
|
||
|
|
||
|
text_string="$1"
|
||
|
filename="$(echo "$text_string" | tr ' ' '_').png"
|
||
|
|
||
|
# Set the desired image width and calculate the height
|
||
|
image_width=200
|
||
|
image_height=$((image_width / 4))
|
||
|
|
||
|
# Calculate the point size based on the length of the text string
|
||
|
point_size=$((image_width / ${#text_string} * 13 / 10))
|
||
|
|
||
|
echo "font_size ${point_size}"
|
||
|
# Set the desired font
|
||
|
font_file="/home/devdesk/.local/share/fonts/5x5_pixel.ttf"
|
||
|
|
||
|
convert -background white -fill black -font "$font_file" -pointsize "$point_size" \
|
||
|
-size "${image_width}x${image_height}" -gravity Center label:"$text_string" "$filename"
|
||
|
|
||
|
echo "PNG file created: $filename"
|
||
|
|
||
|
if [[ "$2" == "debug" ]]; then
|
||
|
echo "Debug mode detected, skipping print."
|
||
|
exit 0
|
||
|
fi
|
||
|
sudo brother_ql -b pyusb --model QL-570 -p usb://0x04f9:0x2028/000M6Z401370 --debug print -l 62 $filename
|