Background Removal Save File

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
Pqdy
Posts: 4
Joined: 2017-08-22T12:37:34-07:00
Authentication code: 1151

Background Removal Save File

Post by Pqdy »

Hello all and thank you for your time and consideration.

OS: Windows 10
Version: ImageMagick 7.0.6-9 Q16 x64 2017-08-21 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC

My goal is to take a folder of PNG images, remove three colors from the background and leave transparent. Ideally I would like them saved to a new folder.

Starting Image: https://drive.google.com/open?id=0B0xHg ... jJuMzdEU3c
Desired Image: https://drive.google.com/open?id=0B0xHg ... jZHdVQtQkk

After searching through forums, tutorials, IM website, examples and the reference index I have come up with this:

C:\Users\pqdyp\Desktop\Landscapecopy>FOR %G IN (*.png) DO Magick "%G -alpha set -transparent #00FFFF -transparent #FF00FF -transparent #FF96FF Batch\%G

Resulting Error: Invalid argument or not enough arguments

It does scroll through all .png files in folder so the first part seems right. I have toyed around with it and yielded different errors. I suspect that I am not saving the output images correctly. I have tried including the full path to desired folder:

C:\Users\pqdyp\Desktop\Batch\%G

I have tried interchanging "magick" with "convert" the later leads to a list of operations usable by Image Magick being displayed.

what am I missing to make this work?

Thank you
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Background Removal Save File

Post by snibgo »

You have a single lonely quote. Quotes usually go in pairs.
snibgo's IM pages: im.snibgo.com
Pqdy
Posts: 4
Joined: 2017-08-22T12:37:34-07:00
Authentication code: 1151

Re: Background Removal Save File

Post by Pqdy »

Thank you for your reply snibgo,

Ah yes, a byproduct of my tinkering. By removing the lonely quote I am left with the error:

Magick: unable to open image 'Batch\AVLrf110.png': No such file or directory @ error/blob.c/OpenBlob/3109.
Magick: WriteBlob Failed `Batch\AVLrf110.png' @ error/png.c/MagickPNGErrorHandler/1711.

This is what led me to believe that I am not saving the files correctly. I love the learning process but I just can't seem to figure this out.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Background Removal Save File

Post by snibgo »

Does the directory "Batch" exist?
snibgo's IM pages: im.snibgo.com
Pqdy
Posts: 4
Joined: 2017-08-22T12:37:34-07:00
Authentication code: 1151

Re: Background Removal Save File

Post by Pqdy »

Yes but as you say that, perhaps it needs to be located in the same directory as the images as I have started everything there.
When I return home I will try that.
Again thank you for your help.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Background Removal Save File

Post by snibgo »

If the directory "Batch" doesn't exist as a subdirectory of where you are running the command, it won't work. Create the directory first.
snibgo's IM pages: im.snibgo.com
Pqdy
Posts: 4
Joined: 2017-08-22T12:37:34-07:00
Authentication code: 1151

Re: Background Removal Save File

Post by Pqdy »

Thank you so much snibgo!

Once I moved the batch folder into the same folder as the images it worked perfectly.
600+ images edited in seconds! Simply marvelous!

Thread Complete
Post Reply