Skip to content

Instantly share code, notes, and snippets.

@JuniorPolegato
Created April 27, 2016 15:41
Show Gist options
  • Select an option

  • Save JuniorPolegato/95dc02fe6cc69471222bd52179d0d97d to your computer and use it in GitHub Desktop.

Select an option

Save JuniorPolegato/95dc02fe6cc69471222bd52179d0d97d to your computer and use it in GitHub Desktop.
Resize images from a folder to another folder
#!/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