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

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
yugu

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

Post 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
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

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

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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
yugu

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

Post 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
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

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

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply