#!/bin/bash guitool=zenity exit_me(){ rm -rf ${tempdir} exit 1 } trap "exit_me 0" 0 1 2 5 15 LOCKFILE="/tmp/.${USER}-$(basename $0).lock" [[ -r $LOCKFILE ]] && PROCESS=$(cat $LOCKFILE) || PROCESS=" " if (ps -p $PROCESS) >/dev/null 2>&1 then echo "E: $(basename $0) is already running" $guitool --error --text="$(basename $0) is already running" exit 1 else rm -f $LOCKFILE echo $$ > $LOCKFILE fi # Dialog box to choose thumb's size SIZE="$( $guitool --list --height=340 --title="Seleccionar el nuevo tamaño" --text="Selecciona la resolución a la que quieres convertir las imágenes" --radiolist --column=$"Marcar" --column=$"Tamaño" "" "Automático (para fotos)" "" "No redimensionar" "" "253x173" "" "320x240" "" "640x480" "" "800x600" "" "1024x768" "" "2048x1080" "" "4096x2160" "" "7680x4320" "" "Otro Tamaño" || echo cancel )" [[ "$SIZE" = "cancel" ]] && exit if [[ "$SIZE" = "Otro Tamaño" ]]; then SIZE="$( $guitool --entry --title="Entrar el tamaño de forma manual" --text="Tecela la resolución a la que quieres convertir las imágenes" --entry-text "1600x1200" || echo cancel )" [[ "$SIZE" = "cancel" ]] && exit fi if [[ "$SIZE" = "" ]]; then $guitool --error --text="Tamaño no especificado. Selecciona el tamaño deseado. " exit 1 fi QUALITY="$( $guitool --entry --entry-text="85" --title="Calidad" --text="Seleccionar la calidad (85 para fotos, 90 para capturas de pantalla)" || echo cancel )" [[ "$QUALITY" = "cancel" ]] && exit [[ -z "$QUALITY" ]] && QUALITY=85 # precache PROGRESS=0 NUMBER_OF_FILES="$#" let "INCREMENT=100/$NUMBER_OF_FILES" ( for i in "$@" do echo "$PROGRESS" file="$i" # precache dd if="$file" of=/dev/null 2>/dev/null # increment progress let "PROGRESS+=$INCREMENT" done ) | $guitool --progress --title "Precaching..." --percentage=0 --auto-close --auto-kill # Creating thumbnails. Specific work on picture should be add there as convert's option # How many files to make the progress bar PROGRESS=0 NUMBER_OF_FILES="$#" let "INCREMENT=100/$NUMBER_OF_FILES" mkdir -p "Images Resized" ( for i in "$@" do echo "$PROGRESS" file="$i" filename="${file##*/}" filenameraw="${filename%.*}" echo -e "# Transformando: \t ${filename}" #!/bin/bash guitool=zenity exit_me(){ rm -rf ${tempdir} exit 1 } trap "exit_me 0" 0 1 2 5 15 LOCKFILE="/tmp/.${USER}-$(basename $0).lock" [[ -r $LOCKFILE ]] && PROCESS=$(cat $LOCKFILE) || PROCESS=" " if (ps -p $PROCESS) >/dev/null 2>&1 then echo "E: $(basename $0) is already running" $guitool --error --text="$(basename $0) is already running" exit 1 else rm -f $LOCKFILE echo $$ > $LOCKFILE fi #!/bin/bash guitool=zenity exit_me(){ rm -rf ${tempdir} exit 1 } trap "exit_me 0" 0 1 2 5 15 LOCKFILE="/tmp/.${USER}-$(basename $0).lock" [[ -r $LOCKFILE ]] && PROCESS=$(cat $LOCKFILE) || PROCESS=" " if (ps -p $PROCESS) >/dev/null 2>&1 then echo "E: $(basename $0) is already running" $guitool --error --text="$(basename $0) is already running" exit 1 else rm -f $LOCKFILE echo $$ > $LOCKFILE fi # Dialog box to choose thumb's size SIZE="$( $guitool --list --height=340 --title="Seleccionar el nuevo tamaño" --text="Selecciona la resolución a la que quieres convertir las imágenes" --radiolist --column=$"Marcar" --column=$"Tamaño" "" "Automático (para fotos)" "" "No redimensionar" "" "253x173" "" "320x240" "" "640x480" "" "800x600" "" "1024x768" "" "2048x1080" "" "4096x2160" "" "7680x4320" "" "Otro Tamaño" || echo cancel )" [[ "$SIZE" = "cancel" ]] && exit if [[ "$SIZE" = "Otro Tamaño" ]]; then SIZE="$( $guitool --entry --title="Entrar el tamaño de forma manual" --text="Tecela la resolución a la que quieres convertir las imágenes" --entry-text "1600x1200" || echo cancel )" [[ "$SIZE" = "cancel" ]] && exit fi if [[ "$SIZE" = "" ]]; then $guitool --error --text="Tamaño no especificado. Selecciona el tamaño deseado. " exit 1 fi QUALITY="$( $guitool --entry --entry-text="85" --title="Calidad" --text="Seleccionar la calidad (85 para fotos, 90 para capturas de pantalla)" || echo cancel )" [[ "$QUALITY" = "cancel" ]] && exit [[ -z "$QUALITY" ]] && QUALITY=85 # precache PROGRESS=0 NUMBER_OF_FILES="$#" let "INCREMENT=100/$NUMBER_OF_FILES" ( for i in "$@" do echo "$PROGRESS" file="$i" # precache dd if="$file" of=/dev/null 2>/dev/null # increment progress let "PROGRESS+=$INCREMENT" done ) | $guitool --progress --title "Precaching..." --percentage=0 --auto-close --auto-kill # Creating thumbnails. Specific work on picture should be add there as convert's option # How many files to make the progress bar PROGRESS=0 NUMBER_OF_FILES="$#" let "INCREMENT=100/$NUMBER_OF_FILES" mkdir -p "Images Resized" ( for i in "$@" do echo "$PROGRESS" file="$i" filename="${file##*/}" filenameraw="${filename%.*}" echo -e "# Transformando: \t ${filename}" if [[ "$SIZE" = "No redimensionar" ]] ; then convert -quality $QUALITY "${file}" "Images Resized/${filename%\.*}.jpg" else if [[ "$SIZE" = "Automático (para fotos)" ]] ; then size_horiz="$( identify "$file" | tr ' ' '\n' | grep -E "[[:digit:]]+x[[:digit:]]+" | head -1 | sed -e 's|x.*$||g' )" if [[ "$size_horiz" -lt 2400 ]] ; then # no need to resize images smaller than 2400 convert -quality $QUALITY "${file}" "Images Resized/${filename%\.*}.jpg" else # 2 / 3 of the original size size_horiz_resized="$( echo "( $size_horiz / 3 ) * 2" | bc -l | sed -e 's|\.*$||g' )" convert -resize ${size_horiz_resized}x${size_horiz_resized} -quality $QUALITY "${file}" "Images Resized/${filename%\.*}.jpg" fi else convert -resize $SIZE -quality $QUALITY "${file}" "Images Resized/${filename%\.*}.jpg" fi fi let "PROGRESS+=$INCREMENT" done ) | $guitool --progress --title "Transformando imagen..." --percentage=0 --auto-close --auto-kill $guitool --info --text="Finalizado, Puedes encontrar las imágenes en el directorio 'Images Resized'" # Dialog box to choose thumb's size SIZE="$( $guitool --list --height=340 --title="Seleccionar el nuevo tamaño" --text="Selecciona la resolución a la que quieres convertir las imágenes" --radiolist --column=$"Marcar" --column=$"Tamaño" "" "Automático (para fotos)" "" "No redimensionar" "" "253x173" "" "320x240" "" "640x480" "" "800x600" "" "1024x768" "" "2048x1080" "" "4096x2160" "" "7680x4320" "" "Otro Tamaño" || echo cancel )" [[ "$SIZE" = "cancel" ]] && exit if [[ "$SIZE" = "Otro Tamaño" ]]; then SIZE="$( $guitool --entry --title="Entrar el tamaño de forma manual" --text="Tecela la resolución a la que quieres convertir las imágenes" --entry-text "1600x1200" || echo cancel )" [[ "$SIZE" = "cancel" ]] && exit fi if [[ "$SIZE" = "" ]]; then $guitool --error --text="Tamaño no especificado. Selecciona el tamaño deseado. " exit 1 fi QUALITY="$( $guitool --entry --entry-text="85" --title="Calidad" --text="Seleccionar la calidad (85 para fotos, 90 para capturas de pantalla)" || echo cancel )" [[ "$QUALITY" = "cancel" ]] && exit [[ -z "$QUALITY" ]] && QUALITY=85 # precache PROGRESS=0 NUMBER_OF_FILES="$#" let "INCREMENT=100/$NUMBER_OF_FILES" ( for i in "$@" do echo "$PROGRESS" file="$i" # precache dd if="$file" of=/dev/null 2>/dev/null # increment progress let "PROGRESS+=$INCREMENT" done ) | $guitool --progress --title "Precaching..." --percentage=0 --auto-close --auto-kill # Creating thumbnails. Specific work on picture should be add there as convert's option # How many files to make the progress bar PROGRESS=0 NUMBER_OF_FILES="$#" let "INCREMENT=100/$NUMBER_OF_FILES" mkdir -p "Images Resized" ( for i in "$@" do echo "$PROGRESS" file="$i" filename="${file##*/}" filenameraw="${filename%.*}" echo -e "# Transformando: \t ${filename}" if [[ "$SIZE" = "No redimensionar" ]] ; then convert -quality $QUALITY "${file}" "Images Resized/${filename%\.*}.jpg" else if [[ "$SIZE" = "Automático (para fotos)" ]] ; then size_horiz="$( identify "$file" | tr ' ' '\n' | grep -E "[[:digit:]]+x[[:digit:]]+" | head -1 | sed -e 's|x.*$||g' )" if [[ "$size_horiz" -lt 2400 ]] ; then # no need to resize images smaller than 2400 convert -quality $QUALITY "${file}" "Images Resized/${filename%\.*}.jpg" else # 2 / 3 of the original size size_horiz_resized="$( echo "( $size_horiz / 3 ) * 2" | bc -l | sed -e 's|\.*$||g' )" convert -resize ${size_horiz_resized}x${size_horiz_resized} -quality $QUALITY "${file}" "Images Resized/${filename%\.*}.jpg" fi else convert -resize $SIZE -quality $QUALITY "${file}" "Images Resized/${filename%\.*}.jpg" fi fi let "PROGRESS+=$INCREMENT" done ) | $guitool --progress --title "Transformando imagen..." --percentage=0 --auto-close --auto-kill $guitool --info --text="Finalizado, Puedes encontrar las imágenes en el directorio 'Images Resized'" if [[ "$SIZE" = "No redimensionar" ]] ; then convert -quality $QUALITY "${file}" "Images Resized/${filename%\.*}.jpg" else if [[ "$SIZE" = "Automático (para fotos)" ]] ; then size_horiz="$( identify "$file" | tr ' ' '\n' | grep -E "[[:digit:]]+x[[:digit:]]+" | head -1 | sed -e 's|x.*$||g' )" if [[ "$size_horiz" -lt 2400 ]] ; then # no need to resize images smaller than 2400 convert -quality $QUALITY "${file}" "Images Resized/${filename%\.*}.jpg" else # 2 / 3 of the original size size_horiz_resized="$( echo "( $size_horiz / 3 ) * 2" | bc -l | sed -e 's|\.*$||g' )" convert -resize ${size_horiz_resized}x${size_horiz_resized} -quality $QUALITY "${file}" "Images Resized/${filename%\.*}.jpg" fi else convert -resize $SIZE -quality $QUALITY "${file}" "Images Resized/${filename%\.*}.jpg" fi fi let "PROGRESS+=$INCREMENT" done ) | $guitool --progress --title "Transformando imagen..." --percentage=0 --auto-close --auto-kill $guitool --info --text="Finalizado, Puedes encontrar las imágenes en el directorio 'Images Resized'"