Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Crop or mask an image into a circle

What is the best way to crop or mask an image into a circular shape, using either ImageMagick or GD libraries? (Note, solution exists on "other" Q&A sites, but not StackOverflow)

like image 829
pix0r Avatar asked Jun 16 '09 01:06

pix0r


People also ask

How do I make an image into a circle?

On the left side panel, click Elements and type “Frames” on the search bar and look for a circular shape. Click your chosen circle frame to apply it to your page. Then, drag and drop your photo into the frame to crop. Double-click the frame to match your preferred photo size.

How do I crop an image into a circle in HTML?

We can crop an image to a circle by adding a border-radius property with value 50% to the square image. Similarly, we can crop background-image to circle by adding border-radius value to 50% .


1 Answers

Here is one way with ImageMagick that will acomplish this without using a mask:

convert -size 200x200 xc:none -fill walter.jpg -draw "circle 100,100 100,1" circle_thumb.png

walteralt text

like image 156
tom Avatar answered Oct 22 '22 05:10

tom