Removing Pixels from Background Image Based On Custom Object

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
travelgravel
Posts: 1
Joined: 2018-11-27T09:08:45-07:00
Authentication code: 1152

Removing Pixels from Background Image Based On Custom Object

Post by travelgravel »

I have gone through the examples and also searched the forums, but have been unable to find a solution to a problem I am trying to handle.

I would like to be able to upload an image, in this example, a picture of my father. I would then make a custom oval object. I would like to be able to move this custom object to where it frames my fathers face in the image and then perform a clipping of the uploaded image. This would remove all pixels outside of my oval object on the uploaded image. I have been able to get an image uploaded and also created an oval object, but am unsure if this clipping that I want is possible. Any ideas?

Thanks for taking a look at my problem. Cheers!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Removing Pixels from Background Image Based On Custom Object

Post by snibgo »

What version of IM? On what platform?

This seems simple, for example, assuming oval.png has a white oval on black background:

Code: Select all

magick father.png oval.png -alpha off -compose CopyOpacity -composite -trim +repage out.png
Does that help? If not, please post links to sample images.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Removing Pixels from Background Image Based On Custom Object

Post by fmw42 »

Please, always provide your IM version and platform when asking questions, since syntax may differ.

Also provide your exact command line and your images, if possible.

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620

If using Imagemagick 7, then see http://imagemagick.org/script/porting.php#cli


For novices, see

http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
https://imagemagick.org/script/porting.php#cli
Post Reply