Estimated read time: 1 minutes


You need imagemagick
installed and this in you .bashrc
. Run with crop selfie.jpg
function crop {
x=$(identify $1 | awk '{print $3}' | cut -d 'x' -f1)
y=$(identify $1 | awk '{print $3}' | cut -d 'x' -f2)
smallest_side=$(( $x > $y ? $y : $x ))
convert $1 -gravity center -crop ${smallest_side}x${smallest_side}+0+0 $1
}