#! /bin/sh ######################################################################### # ImageScript v 0.6 By Valentin Barral, 2008 - Brigantio.com ######################################################################### # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # ########################################################################## # Valores por defecto TAMGRA="800x800" TAMPEQ="500x500" CAL=75 ############################################################## # Calculamos cuanto sube la barra de progreso con cada fichero ############################################################## PROGRESO=0 NUM_FIC=$# let "INCREMENTO=100/$NUM_FIC" ############################################################ # Mostramos el dialogo con las opciones ########################################################### OPCIONES=`zenity --list --height 260 --title "Escoge opciones" --text "Marca lo que quieras cambiar.\n Por defecto: 800px y calidad 75." --checklist --column "" --column "Opcion" FALSE "Miniaturas" FALSE "Marca de agua" FALSE "Seleccionar calidad" FALSE "Escoger dimensiones" --separator=":"` if [ "$?" != 0 ] ; then exit fi MINIATURAS=0 MARCA=0 CALIDAD=0 TAM=0 OP1=`echo $OPCIONES|cut -f1 -d:` OP2=`echo $OPCIONES|cut -f2 -d:` OP3=`echo $OPCIONES|cut -f3 -d:` OP4=`echo $OPCIONES|cut -f4 -d:` if [ "$OP1" = "Miniaturas" ]; then MINIATURAS=1; else MINIATURAS=0; fi if [ "$OP1" = "Marca de agua" -o "$OP2" = "Marca de agua" ]; then MARCA=1; else MARCA=0; fi if [ "$OP1" = "Seleccionar calidad" -o "$OP2" = "Seleccionar calidad" -o "$OP3" = "Seleccionar calidad" ]; then CALIDAD=1; else CALIDAD=0; fi if [ "$OP1" = "Escoger dimensiones" -o "$OP2" = "Escoger dimensiones" -o "$OP3" = "Escoger dimensiones" -o "$OP4" = "Escoger dimensiones" ]; then TAM=1; else TAM=0; fi ####################################################### # Mostramos los dialogos para cambiar de tamano ####################################################### if [ $TAM -eq 1 ]; then t=`zenity --list --height 300 --title="Escoge tamano" --text "Dimension imagen GRANDE:" --radiolist --column "" --column "Tamano" FALSE 480 FALSE 600 FALSE 640 FALSE 768 TRUE 800 FALSE 1024 FALSE 1280 FALSE 1440`; if [ "$?" != 0 ] ; then exit fi TAMGRA="$tx$t" if [ $MINIATURAS -eq 1 ]; then p=`zenity --list --height 300 --title="Escoge tamano" --text "Dimension MINIATURAS:" --radiolist --column "" --column "Tamano" FALSE 150 FALSE 200 FALSE 300 FALSE 400 TRUE 500 FALSE 600`; if [ "$?" != 0 ] ; then exit fi; TAMPEQ="$px$p" fi fi ######################################################################### # Mostramos un dialogo para especificar la calidad ######################################################################### if [ $CALIDAD -eq 1 ]; then CAL=`zenity --scale --title="Calidad" --text "Escoge la calidad" --min-value=50 --max-value=100 --value=75 --step 2`; if [ "$?" != 0 ] ; then exit fi; fi ############################################################# # Mostramos dialogo para introducir marca de agua ############################################################# if [ $MARCA -eq 1 ]; then ETIQUETA=`zenity --entry --title="Marca de agua" --text="Escribe el texto que quieras poner:" --entry-text "Brigantio.com"`; if [ "$?" != 0 ] ; then exit fi; fi ############################################################## # Creamos los directorios necesarios ############################################################## mkdir -p convertidos cd convertidos mkdir -p grandes if [ $MINIATURAS -eq 1 ]; then mkdir -p miniaturas fi ####################################################### # Creamos la marca de agua ####################################################### if [ $MARCA -eq 1 ]; then mkdir -p marca; mkdir -p pregrandes mkdir -p prepe convert -size 300x50 xc:grey30 -font Verdana -pointsize 30 -gravity center \ -draw "fill grey70 text 0,0 '$ETIQUETA'" \ marca/stamp_fgnd.png; convert -size 300x50 xc:black -font Verdana -pointsize 30 -gravity center \ -draw "fill white text 1,1 '$ETIQUETA' \ text 0,0 '$ETIQUETA' \ fill black text -1,-1 '$ETIQUETA'" \ +matte marca/stamp_mask.png; composite -compose CopyOpacity marca/stamp_mask.png marca/stamp_fgnd.png marca/marca.png mogrify -trim +repage marca/marca.png; fi cd .. ####################################################### # Creamos las imagenes, las miniaturas y marcamos todo ####################################################### if [ $MARCA -eq 1 ]; then (for i in $*; do echo "$PROGRESO"; echo "# Procesando $i"; convert -resize $TAMGRA -quality $CAL $i convertidos/pregrandes/$i; composite -gravity south-east -geometry +30+20 -dissolve 100 convertidos/marca/marca.png convertidos/pregrandes/$i convertidos/grandes/$i; if [ $MINIATURAS -eq 1 ]; then convert -resize $TAMPEQ -quality $CAL $i convertidos/prepe/$i; composite -gravity south-east -geometry +30+20 -dissolve 100 convertidos/marca/marca.png convertidos/prepe/$i convertidos/miniaturas/$i; fi let "PROGRESO+=$INCREMENTO" done) | zenity --progress --title "Trabajando..." --percentage=0; else (for i in $*; do echo "$PROGRESO"; echo "# Procesando $i"; convert -resize $TAMGRA -quality $CAL $i convertidos/grandes/$i if [ $MINIATURAS -eq 1 ]; then convert -resize $TAMPEQ -quality $CAL $i convertidos/miniaturas/$i fi let "PROGRESO+=$INCREMENTO" done) | zenity --progress --title "Trabajando..." --percentage=0; fi ######################################################## # Borramos archivos temporales ######################################################## if [ $MARCA -eq 1 ]; then rm -R convertidos/marca; rm -R convertidos/pregrandes rm -R convertidos/prepe fi