How to extract ngon using commandline (magick.exe)

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
allexx
Posts: 9
Joined: 2019-01-19T10:39:56-07:00
Authentication code: 1152

How to extract ngon using commandline (magick.exe)

Post by allexx »

Hello! I'm on Windows/IM 7, and am looking to extract an n-gon (polygon of n vertices) from a JPG.

For example, given an image that is large enough, I want to extract an n-gon described by the vertices [ (10,10), (10,20), (70,65), (60,55) ]

This SO question answers just that using C++; is there a standard commandline equivalent (using magick.exe?) pls?

( Will post back here if I find reference + translate, myself )
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to extract ngon using commandline (magick.exe)

Post by fmw42 »

Use the equivalent of -draw "polygon ..." to create a mask and then use the mask to make the background transparent, then trim if desired to the bounding box of the polygon region. Sorry I do not code in Windows or C++.
allexx
Posts: 9
Joined: 2019-01-19T10:39:56-07:00
Authentication code: 1152

Re: How to extract ngon using commandline (magick.exe)

Post by allexx »

Thank you, Fred! Searching for "imagemagick -draw polygon" brought up a post for exactly what I asked for:
-- this: http://www.multipole.org/discourse-serv ... hp?t=25286
-- which led to this: https://www.imagemagick.org/discourse-s ... =1&t=25228
Post Reply