Index ¦ All posts

:~$ crop

Estimated read time: 1 minutes

  
Here is quick way of automaticly cropping images without fiddeling with image sizes.

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
}

© Torvald Tåke. Built using Pelican. Theme by Giulio Fidente on github.