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.


3 Answers 3


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

enter image description here enter image description here enter image description here

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:\Users\Eric\Pictures\pngs\logos

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"

Note: With ImageMagick v7, use magick instead of convert, as so

FOR %G IN (*.png) DO magick "%G" -transparent #FF00FF "batch\%G"

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

enter image description here enter image description here enter image description here

  • 1
    good solution, if anyone wondering equivalent linux bash: for file in *.png ; do convert "${file}" -transparent '#ffcc66' "batch/${file}" ; done Oct 21, 2014 at 10:08
  • For Mac this seems to be related: superuser.com/questions/773590/… Thanks! Aug 9, 2016 at 2:55
  • This doesn't work like Gimp does. If you have a white pixel with alpha 0.5 on top of a black pixel, and you want to remove the black color, the gray pixel will remain. May 30, 2017 at 7:45

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.

  • I have that and have used it to mass crop these images, but there does not appear to be any option to replace colors. Maybe I'm missing it though, or have an old version?
    – plex
    Feb 21, 2013 at 23:11
  • I do not know. I'm just familiar with the plug-in because a client was using it to mass edit images and was getting an error. As John has posted Imagemagick is a powerful option and could solve all your problems. There site is very detailed. Have a look imagemagick.org/script/index.php
    – user9447
    Feb 21, 2013 at 23:15

This worked like a charm for me:


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"


Not the answer you're looking for? Browse other questions tagged or ask your own question.