Remove background in batch

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
ricardo7227
Posts: 2
Joined: 2015-09-05T16:07:08-07:00
Authentication code: 1151

Remove background in batch

Post by ricardo7227 »

Hello guys, Im new in this software.
I need to remove background of multiple images, i try with this code:

Code: Select all

composite -compose difference overlay.jpg background.jpg diff.png
convert diff.png -threshold 2600 mask.png
convert overlay.jpg mask.png -alpha off -compose CopyOpacity -composite Final.png
and it works!!
example:
original
Image
background
Image
Result:
Image

Although, How i can convert this code for a batch?
ImageImageImageImageImageImageImage

But i don´t know how to use mogrify. :shock:
Thank you very much. :(
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Remove background in batch

Post by fmw42 »

see
http://www.imagemagick.org/Usage/basics/#mogrify
http://www.imagemagick.org/Usage/basics ... fy_compose

But mogrify will only allow one image in the command line, except for a pre-prepared composite image. So if you cannot make your commands into one convert command with one image and one overlay, then you will need to write a script loop over all the files you want to process.

You should change your composite command to a convert and then try to make all three commands into one convert.

see convert syntax at
http://www.imagemagick.org/Usage/compose/#compose
ricardo7227
Posts: 2
Joined: 2015-09-05T16:07:08-07:00
Authentication code: 1151

Re: Remove background in batch

Post by ricardo7227 »

ok, I go to see them
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Remove background in batch

Post by fmw42 »

With two composites, I do not think you can use mogrify. You would have to run one mogrify to do the difference and another on the results of the first to do the copy_opacity.
Post Reply