cercle crop or masking through imaghmagick.......

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
soumya007

cercle crop or masking through imaghmagick.......

Post by soumya007 »

Hello all,

I'm trying to crop an image using imagemagic and I have done it successfully in general way. But now i'm trying to crop or mask it in cercle shape. I have tried many things but didn't find any luck.

If you guyz have any idea then please help me out. This is very urgent for me.

Thanks in advance

Regards - Soumya

P.S: You can also write to me at soumyajit.soumya@gmail.com
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: cercle crop or masking through imaghmagick.......

Post by anthony »

To crop a circle you must create a circle mask, to make parts of your original image transparent.

See IM exmaples, Channels and Masking
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: cercle crop or masking through imaghmagick.......

Post by Bonzo »

One way I have done it:

Code: Select all

<?php
exec("convert -size 400x300 xc:white -fill orange -draw \"circle 200,150 200,3\" \\
-gaussian 1x1 -transparent orange mask.png");

exec("convert ../original_images/sunflower.jpg mask.png -composite round.jpg");

unlink( 'mask.png' );
?> 
http://www.rubblewebs.co.uk/imagemagick ... =round.jpg
Post Reply