Page 1 of 1

Help! How to select an ellipse region and then extract it?

Posted: 2009-03-05T06:27:31-07:00
by yugu
I've been reading ImageMagick documents, browsed the forum for a couple of week, but I still don't know how to cope with my task.
What I need is to select an ellipse region in the initial .jpg-file.
Then extract it. And place on transparent background.

Can anybody help me? It would be enough if you suggest me steps or ImageMagick commands sequence.

Many thanks in advance.
Yugu

Re: Help! How to select an ellipse region and then extract it?

Posted: 2009-03-05T12:40:48-07:00
by Bonzo
I can not remember how to draw an eclipse but this should do it with a rounded rectangle you just need to modify the code.

Code: Select all

convert -size 637x140 xc:none -fill white -draw "roundRectangle 0,0 637,140 15,15" input.jpg -compose SrcIn -composite output.png

Re: Help! How to select an ellipse region and then extract it?

Posted: 2009-03-05T13:41:54-07:00
by fmw42
Bonzo wrote:I can not remember how to draw an eclipse but this should do it with a rounded rectangle you just need to modify the code.

Code: Select all

convert -size 637x140 xc:none -fill white -draw "roundRectangle 0,0 637,140 15,15" input.jpg -compose SrcIn -composite output.png

For drawing ellipse, see http://www.imagemagick.org/Usage/draw/#primitives

Re: Help! How to select an ellipse region and then extract it?

Posted: 2009-03-08T03:12:10-07:00
by yugu
Bonzo, fmw42, thank you very very much!!
In my case to draw an ellipse on a 240x320 image near the center the following command helped

Code: Select all

convert -size 240x320 xc:none -fill white -draw "ellipse 126,162 55,70 0,360" input.jpg -compose SrcIn -composite output.png

Re: Help! How to select an ellipse region and then extract it?

Posted: 2009-03-09T16:16:15-07:00
by anthony
More typically you would read the input file first then use DstIn. That way any meta data in the (first) destination image is preserved in the output image, the same goes for the image size.

The source image can then be any size and given an offset using -geometry.