Steven
Steven

Reputation: 13975

ImageMagick Crop Square from Circle?

I have a 424x318 image that I "draw" a circle into and leave the rest transparent. I want to then take that circle and crop it out. How can I do this?

My function (the bash variables are just the normal stuff, $SCALEFILE is the file, $NEWFILE is what it saves it as and $SIZE is just the normal size string x0,y0 x1,y1)

convert -size 416x318 xc:none -fill $SCALEFILE -draw "circle $SIZE" $NEWFILE

ps. my circle dimensions change.

Thanks!

Upvotes: 2

Views: 1607

Answers (1)

Russell Zahniser
Russell Zahniser

Reputation: 16354

You can use -crop WxH+X+Y +repage to crop to the circle.

For example:

convert -size 300x300 xc:transparent -fill "image.png" -draw "circle 240,90 290,90" -crop 100x100+190+40 +repage circle1.png
convert -size 300x300 xc:transparent -fill "image.png" -draw "circle 70,90 110,90" -crop 100x100+20+40 +repage circle2.png

enter image description here

Upvotes: 1

Related Questions