protege-DNI/protege-dni.sh

51 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
# Tamano oficial DNI (3.0 y 4.0) es 85,60x53,98 mm
# Solicitar ficheros origen del DNI (Anverso y Reverso)
zenity --info --text="Seleccione la imagen con el ANVERSO"
ANVERSO=$(zenity --file-selection)
zenity --info --text="Seleccione la imagen con el REVERSO"
REVERSO=$(zenity --file-selection)
# Ficheros temporales (escalado)
AnvTMP="${ANVERSO%.*}-tmp.jpg"
RevTMP="${REVERSO%.*}-tmp.jpg"
# Ficheros Salida
AnvIMG="${ANVERSO%.*}-protegido.jpg"
RevIMG="${REVERSO%.*}-protegido.jpg"
# Anverso Zona de Bloques de ocultacion
CAN='800,370,1000,605'
SOPORTE='400,440,570,485'
# Reverso Zona de Bloques de ocultacion
EQUIPO='5,177,100,355'
PADRES='280,317,620,376'
IDE='50,430,980,520'
# Pedimos texto al usuario
TEXTO=$(zenity --entry --text="Escriba el mensaje a poner en la imagen" --entry-text="SOLO PARA USO INTERNO DE ")
# Temporales Escalados
echo "Preparando Imagenes temporales (escaladas).."
convert "$ANVERSO" -resize 1011x638 -units PixelsPerInch -density 150 "$AnvTMP" 2>/dev/null
convert "$REVERSO" -resize 1011x638 -units PixelsPerInch -density 150 "$RevTMP" 2>/dev/null
echo "Ocultando, fijando texto y escala gris en ANVERSO"
convert "$AnvTMP" -fill gray -draw "rectangle $CAN" -fill gray -draw "rectangle $SOPORTE" -font helvetica -fill black -pointsize 30 -gravity center -annotate 0 "$TEXTO" -grayscale average -units PixelsPerInch -density 150 "$AnvIMG"
echo "Ocultando, fijando texto y escala gris en REVERSO"
convert "$RevTMP" -fill gray -draw "rectangle $EQUIPO" -fill gray -draw "rectangle $PADRES" -fill gray -draw "rectangle $IDE" -font helvetica -fill black -pointsize 30 -gravity center -annotate 0 "$TEXTO" -grayscale average -units PixelsPerInch -density 150 "$RevIMG"
echo "Limpiando temporales..."
rm "$AnvTMP" "$RevTMP"
echo
echo "-----------------------------------------------"
echo "Imagenes de DNI Listas y protegidas para envio"
echo " Anverso: $AnvIMG"
echo " Reverso: $RevIMG"
echo "-----------------------------------------------"
echo