Crates.io | text2img |
lib.rs | text2img |
version | 0.8.3 |
source | src |
created_at | 2022-04-27 17:21:48.261476 |
updated_at | 2022-04-27 17:57:56.116036 |
description | Creates a png image from text. Useful to protect sensitive information from bots and scrapers, such as email addresses and telephone numbers in web pages, and even passwords sent via email |
homepage | |
repository | https://github.com/apps4uco/text2img |
max_upload_size | |
id | 576127 |
size | 368,394 |
Command line utility and (soon to be) library.
Banner created using
text2img -o text2img.png -s 80 -w 30 "Text 2 Image"
cargo install text2img
Creates a png image from text, with an easy to use command line tool and/or library.
The idea is to be able to show sensitive information and defeat Optical Character Recognition (OCR).
Useful to protect text from bots and scrapers, such as email addresses and telephone numbers in web pages, and even passwords or tokens sent via email.
The image size is calculated automatically so that the text fits, with a small margin. The background is transparent so that the image can be used on any color background.
You can change the font size (-s) also to make it harder for bots and scrapers to do OCR on the text there is an option (-w) to only fill in a percentage of the pixels at random.
If the text has spaces it must be put in quotes on the command line.
USAGE:
text2img [OPTIONS] --output <OUTPUT> <TEXT>
ARGS:
<TEXT> Text to render
OPTIONS:
-h, --help Print help information
-o, --output <OUTPUT> Output filename. Currently only png format is supported
-s, --size <SIZE> Point size of text [default: 20]
-V, --version Print version information
-w, --weight <WEIGHT> Weight 1 to 100 [default: 100]
text2img -o email.png myemail@example.com
50 point font
text2img -o email_size50.png -s 50 myemail@example.com
30% of pixels filled in.
Note: you probably want to make the font bigger so that the text is easier to read.
text2img -o email_weight30.png -w 30 -s 80 myemail@example.com
Currently only Roboto is supported.
The Roboto font used was copied from
/usr/share/fonts/truetype/roboto/unhinted/RobotoTTF/Roboto-Regular.ttf
Submit an issue if you would like a feature, or send a PR if you would like to contribute.
Render the text using Poisson Disks to make it even harder for OCR to work.
Currently the background is always transparent.
text2img -s 12 --font DejaVu -o email.png "myemail@example.com"
echo data.txt | text2img -o data.png
echo data.txt | text2img --justify -o data.png --center --left --right
The alternatives given require the output image size to be specified.
text2image
convert -size 360x360 xc:white -font "FreeMono" -pointsize 12 -fill black -draw @ascii.txt image.png
text 15,15 " text to show
"
convert -size 360x360 xc:white -font "FreeMono" -pointsize 12 -fill black -annotate +15+15 "@ascii.txt" image.png
convert -list font | grep Font:
#!/bin/sh
$1 | convert -background black -fill white \
-font Helvetica -pointsize 14 \
-border 10 -bordercolor black \
label:@- $2