Skip to content

Instantly share code, notes, and snippets.

@chsh
Created April 14, 2022 05:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chsh/ad8992d4ca478c10f1f16c1a534ecda6 to your computer and use it in GitHub Desktop.
Save chsh/ad8992d4ca478c10f1f16c1a534ecda6 to your computer and use it in GitHub Desktop.
Crop square image to circle.
#!/bin/bash
#
# usage: to-path.sh files(to crop circle)
#
for path in "$@"
do
convert $path \( +clone -threshold -1 -negate -fill white -draw "circle `identify -format %w $path | awk '{print $1/2}'`, `identify -format %h $path | awk '{print $1/2}'` `identify -format %w $path | awk '{print $1/2}'`, 0" \) -alpha Off -compose copy_opacity -composite circle-`basename $path`
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment