Skip to content

Instantly share code, notes, and snippets.

@jnsdbr
Created September 24, 2014 12:55
Show Gist options
  • Save jnsdbr/a0e428a948b6e268d3a8 to your computer and use it in GitHub Desktop.
Save jnsdbr/a0e428a948b6e268d3a8 to your computer and use it in GitHub Desktop.
Image modifiers
#!/bin/bash
find . -type f -name "*.jpg" | while read line
do
dir=${line%/*}
file=${line/##*/}
file=${file}
convert "${file}" -resize 400 "resized/${file}"
done
#!/bin/bash
find . -type f -name "*.jpg" | while read line
do
dir=${line%/*}
file=${line/##*/}
file=${file}
read -r _file _file2 _width _height <<< $(convert -format "%f %w %h" "${file}" info:)
filename="$_file $_file2"
width=$_width
height=$_height
if (($width > $height)); then
echo "Rotated -> ${filename}"
mogrify -rotate 90 "${filename}"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment