README

              A tool for writing banners on cash receipts.
                     Works on mac, linux* and *bsd
                              CC4r license
          ___________________________________________________ 
         ╱  |)   _,         _|   _  _.  _  |\  _   ,  |)  *  ╲
         ╲  |/\_/ |  /|/|  / |  |/ / | / \_|/ |/  / \_|/\    ╱
         ╱  /\/ \/|_/ | |_/\/|_/|_/  |/\_/ |_/|_/o \/ |  |/  ╲
         ╲____________________________* banner, streamer ____╱
                                                

We use the -label flag of the image magick convert command to
generate the text contained in the MESSAGE variable on a white background.
The image is saved as a png and is named according to the number of
seconds passed since January 1, 1970. (see: Posix time)
Then, we calculate a cross product of the image obtained to have the
length of the ticket in millimeters to print.
We send this image to the printer via the lp command of the utility
cups, specifying the dimensions calculated in millimeters.

Dependencies
* image magick (Licence ImageMagick →
  https://imagemagick.org/script/license.php): software to generate
  and process one or more images → https://imagemagick.org/
* cups (Apache 2.0): an interface to communicate with
  printers → https://openprinting.github.io/cups

_______________________________________________________________________
                           /!\ important /!\ 
banderole.sh is supplied WITHOUT a thermal printer. It is necessary
to have access to such a tool to print a banner. I use a
Epson TM-T20II which prints up to 80mm wide and connects via USB,
there are plenty of others, you have to hunt around...
_______________________________________________________________________

             Written at erg during the winterschool of 2024

banderole.sh
#!/usr/bin/env sh

# TODO apply patch from Arthur (sept 2024)

H_px=256
# Hauteur imprimable sur un ticket de 80mm
H_mm=68.5
s(){ echo "$1" | iconv -c -t ascii//TRANSLIT | sed -E 's/[^a-zA-Z0-9]+/-/g';}

imprimer() {

OUT=$(s "$1")-$(date +%s).png
magick -background white -fill black \
		-size x$H_px \
		-font NotComic.ttf label:"$1" \
		-rotate -180 \
		-scale 1:4 \
		$OUT

# produit en croix
L_px=$(identify -format "%[fx:w]" $OUT)
L_mm=$(bc -l <<< "$L_px * $H_mm / $H_px") 

lp $OUT \
	-d EPSON_TM-T20II-42C \
	-o PageSize=Custom."$H_mm"x"$L_mm"mm \
	-o TmtSpeed=1
}

imprimer "A tool for writing banners on cash receipts."