php - 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.





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

People are also looking for solutions to the problem: php - Environment variables in route annotations


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.