Created
April 27, 2016 15:41
-
-
Save JuniorPolegato/95dc02fe6cc69471222bd52179d0d97d to your computer and use it in GitHub Desktop.
Resize images from a folder to another folder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| ORIG="`zenity --file-selection --directory \ | |
| --title "Pasta com as imagens originais"`" | |
| echo "ORIG: $ORIG" | |
| if [ -z "$ORIG" ]; then | |
| exit 1 | |
| fi | |
| DEST="`zenity --file-selection --directory \ | |
| --title "Pasta para as imagens redimensionadas"`" | |
| echo "DEST: $DEST" | |
| if [ -z "$DEST" ]; then | |
| exit 1 | |
| fi | |
| if [ "$ORIG" == "$DEST" ]; then | |
| zenity --error\ | |
| --text="As pastas de origem e destino precisam ser diferentes!" | |
| exit 1 | |
| fi | |
| PERCENT="`zenity --scale \ | |
| --text="Novo tamanho das imagens" \ | |
| --value=50 \ | |
| --min-value=1 \ | |
| --max-value=400`%" | |
| echo "PERCENT: $PERCENT" | |
| total="`ls "$ORIG" | wc -l`" | |
| atual=1 | |
| ls "$ORIG" | while read img; do | |
| echo "$img" >&2 | |
| convert "$ORIG/$img" -resize $PERCENT "$DEST/$img" | |
| echo $((atual * 100 / total)) | |
| ((atual++)) | |
| done | | |
| zenity --progress \ | |
| --title="Redimensionamento" \ | |
| --text="Redimensionando imagens..." \ | |
| --auto-close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment