#!/bin/bash # prend un chaine de caractère et affiche quatre images: # deux lisibles plus ou moins mais en 2026 résistantes à l'OCR # deux illisible à l'oeil nu n'apportant aucune sécurité supplémentaire OCR test "$DEBUG" || DEBUG=0 # enleve le debug sauf heritage test $DEBUG = 0 || test $DEBUG = 1 || DEBUG=1 # debug pour autres valeurs test $DEBUG = 1 && echo "$0 : $LINENO mode DEBUG=1" && trap exit 2 test "$1" || exec echo "$0 : [-x|-l] il faut un texte à illustrer" set set $(getopt -u -olx -- $*) # on gère les cotes shift while test "$1" != "--"; do test \-x = "$1" && X=X # remplace les tirets par des espaces et affiche les mots ligne par ligne test \-l = "$1" && S=2 # allege le brouillage pour plus de lisibilité mais moins de sécurité shift done shift test $DEBUG = 1 && echo "$0 : $LINENO : X=$X S=$S $*" D=$(mktemp -d -t imagesD-XXXX) test $DEBUG = 1 && echo "$0 : $LINENO : D=$D repertoire temporaire" F=$(mktemp -p $D -t imageF-XXXX.png) test $DEBUG = 1 && echo "$0 : $LINENO : F=$F" T=25 # taille originale des caractères trop faible pour l'OCR U=100 # taille agrandie déformée test "$B" || B=1 # taille des lignes par defaut test "$S" || S=3 # brouillage par defaut test "$V" || V=4 # taille des lignes par defaut if test "$X" = X then V="$((2*$V))" test $DEBUG = 1 && echo "$0 : $LINENO : X=$X plusieurs lignes ($*)" set $(tr - \ <<< "$*" | tr \. \ ) convert -pointsize $T label:"$1" $F; test $DEBUG = 1 && echo "$0 : $LINENO : *=$*" shift test $DEBUG = 1 && echo "$0 : $LINENO : *=$*" G=$(mktemp -p $D -t imageG-XXXX.png) test $DEBUG = 1 && echo "$0 : $LINENO : G=$G" for i in $*; do test $DEBUG = 1 && echo "$0 : $LINENO : i=$i" convert -pointsize $T label:"$i" $G; convert - $G -append $F < $F done test $DEBUG = 0 && rm -f $G test $DEBUG = 1 && echo "$0 : $LINENO affiche $F ($(identify $F))" && display $F else convert -pointsize $T label:"$*" $F test $DEBUG = 1 && echo "$0 : $LINENO : une seule ligne ($*) affiche $F ($(identify $F))" && display $F fi eval $(identify $F | awk '{print $3}' | sed -e 's/^/XL=/' -e 's/x/ YH=/') test $DEBUG = 1 && echo "$0 : $LINENO taille de $F XL=$XL YH=$YH" convert -resize $(($XL*$U/$T))x$(($YH*$U/$T)) - $F < $F test $DEBUG = 1 && echo "$0 : $LINENO agrandissement de $F ($(identify $F)) > $(($XL*$U/$T))x$(($YH*$U/$T))" && display $F convert -spread $S -emboss $B - $F < $F test $DEBUG = 1 && echo "$0 : $LINENO flou" eval $(identify $F | awk '{print $3}' | sed -e 's/^/XL=/' -e 's/x/ YH=/') test $DEBUG = 1 && echo "$0 : $LINENO taille de $F XL=$XL YH=$YH" XLR=$(($XL*$RANDOM/32767/5)) YHR=$(($YH*$RANDOM/32767/5)) LINE="$XLR,$YHR,$(($XL - $XLR)),$(($YH - $YHR))" convert -stroke black -strokewidth $V -draw "line $LINE" - $F < $F XLR=$(($XL*$RANDOM/32767/5)) YHR=$(($YH*$RANDOM/32767/5)) LINE="$(($XL - $XLR)),$YHR,$XLR,$(($YH - $YHR))" convert -stroke black -strokewidth $V -draw "line $LINE" - $F < $F test $DEBUG = 1 && echo "$0 : $LINENO deux traits $LINE ($(identify $F))" && display $F display < $F & # quand le display est trop long a partir le programme a déjà effacé le fichier tesseract $F - test $DEBUG = 0 && rm -fr $D