4

I want to crop images in PHP. Cropping in rectangular shape is all common and easy to do. Can you guide me that how i can crop image in shape other than square like in oval or round shape. Cropped

Original Image

Baba
  • 94,024
  • 28
  • 166
  • 217
sulmanpucit
  • 456
  • 6
  • 17
  • 4
    dude, its not the 80's anymore. –  Apr 09 '12 at 09:23
  • You should look into anti-aliasing and images with opacity (such as PNG). I'm not aware of any PHP libraries that can do image cutting on an arbitrary path (as per your example) but it should be possible. Maybe look at the code in `GIMP` to see whether you could use any of that? – halfer Apr 09 '12 at 09:47
  • @Dagon - true. [Neither is it the 1980s or the '80s](http://www.wikihow.com/Use-Apostrophes)! – halfer Apr 09 '12 at 09:51

2 Answers2

3

You can actually do that with ImageMagick ... See Crop or mask an image into a circle and Crop image into circle and add border for good examples

Community
  • 1
  • 1
Baba
  • 94,024
  • 28
  • 166
  • 217
0

In addition to the previous answer, you can even blur the border with Image Magick's vignette effect, look for vignetteImage method.

Dmitry Smirnov
  • 128
  • 1
  • 2
  • 7