Mobile app version of vmapp.org
Login or Join
Reiling762

: Batch replacing color with transparency I have a very large number of PNG images (too many to practically do one at a time) with a bright pink background and would like to replace the background

@Reiling762

Posted in: #BatchProcessing #Transparency

I have a very large number of PNG images (too many to practically do one at a time) with a bright pink background and would like to replace the background color with transparency. If this is not possible or particularly difficult, replacing the specified color with white would be useful.

I have gimp but not photoshop and am not particularly comfortable with command line, so if a solution requires that please show each step. It'd be great to be able to do this, any help would be appreciated.

10.03% popularity Vote Up Vote Down


Login to follow query

More posts by @Reiling762

3 Comments

Sorted by latest first Latest Oldest Best

 

@Vandalay110

This worked like a charm for me:
photobatch.wikidot.com/action-color-to-alpha
Phatch is a Photo Batch Processor. Color to alpha action does exactly what you are looking for:

"The value of the color which should become transparent"

10% popularity Vote Up Vote Down


 

@Smith574

If you are running gimp and are not wanting to go Imagemagick you might want to take a look at David’s Batch Processor (DBP). It is a plug-in for gimp for batch processing. Note I have never used it nor tested it but it was something I have seen used before. If you had Photoshop I could show you how to use the batch or action.

10% popularity Vote Up Vote Down


 

@Ravi4787994

I know you said you're not comfortable with command line tools, but ImageMagick can do this:


Replace a Specific Color

convert balloon.gif -transparent blue balloon_trans.gif




Where balloon.gif is the source image, -transparent specifies that you want a transparent bg, blue is the color you want to replace, and balloon_trans.gif is the completed image.

This is under the assumption that your "bright pink" is not part of any of the images. For a little more intelligent background removal (floodfill), check out this tutorial: Masking Simple Backgrounds (floodfill)

This can get a little hairy and some of the options they specify there probably aren't required for what you're trying to do, so as @graphics man suggests you can add background to the command



If you can tell me what OS you're using and a sample image, I can help you with a script to automate this for many images



Specific to your situation:

First, install ImageMagick. You may need to restart after installation for your PATH variable to be updated (I did)

Once it's installed, fire up a command prompt (Start Menu, type cmd, hit enter)

You need to change directories to where the images are saved. For your situation, enter the following command:

cd C:UsersEricPicturespngslogos

Now we need to make a folder to save all the images in:

mkdir batch

And now, the command to convert all the images:

FOR %G IN (*.png) DO convert %G -transparent #FF00FF batch%G

If everything went smoothly, the newly saved images should be in the batch folder you created.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme