make getpeername() return the original socket address which before it was intercepted
[hband-tools.git] / user-tools / text2img-dataurl
blob2891cd9bcc45eb3d1777dc5fda07a61140d19bf4
1 #!/bin/bash
3 true <<EOF
4 =pod
6 =head1 NAME
8 text2img-dataurl - Convert text input to image in "data:..." URL representation
10 =cut
12 EOF
14 report_size()
16 msgprefix="$1" perl -pe '$s += length $_; END { 1 while $s =~ s/(\d)(\d\d\d)(( \d\d\d)*)$/\1 \2\3/; print STDERR "$ENV{msgprefix}$s bytes\n"; }'
19 input=`cat | report_size 'input size: '`
20 echo -n 'data:image/png;base64,'
21 convert -background none -font /usr/share/fonts/truetype/freefont/FreeSans.ttf "$@" label:"$input" png:- |\
22 report_size 'image size: ' | base64 | tr -d "\n" |\
23 report_size 'base64 size: '