Skip to main content

How To Bulk Remove White Or Any Color Solid Background From Image

By February 13, 2017Blog, Shell/Terminal, Snippets
Bulk Remove Solid Background ImageMagick

In this blog post I will show you how to, in bulk, remove any color background to from any image.


  1. ImageMagick
  2. All of your images in one folder

How To Easily Install ImageMagick for Mac OSX

  1. First we install HomeBrew:
    /usr/bin/ruby -e "$(curl -fsSL"


  2. Then we install ImageMagick:
    brew install ImageMagick


  3. Test that ImageMagick is installed by running the command magick, which should give you output with usage instructions

Removing Backgrounds From Images In Bulk

Once we have ImageMagick installed, we can begin to remove solid background colors like magic!

Here’s the command we will be working with:

find . -type f -name "*.jpg" -print0 | while IFS= read -r -d $'\0' file; do convert -verbose "$file" -transparent white "$file.png"; done
# Credit:

To break this command down…

  1. First we are looking for all of the files with the extension .jpg. If you files have a different extension, just change that to whatever you need.
  2. Then we loop through all of the photos and convert white background to transparent
  3. At the same time of the loop, we convert the jpg file format to png (which support transparency)

The values in bold in my breakdown are the values that we can change. For example, let’s say we want to convert a black background to blue, we would run the following command:

find . -type f -name "*.jpg" -print0 | while IFS= read -r -d $'\0' file; do convert -verbose "$file" blue black "$file.png"; done

If you find that there are some remnants of the white background you may need to add fuzz to the command, so it will like like:

convert /Users/mike/Downloads/photo\ work/transparent/your.png  -fuzz 20% -transparent white result.png

20% fuzz is a good place to start. Below are some example of how fuzz changes the output.

ImageMagick Avocado - Original ImageMagick Avocado - No Fuzz

Original vs. Transparent Background (No Fuzz)

ImageMagick Avocado - 20% Fuzz ImageMagick Avocado - 40% Fuzz

20% Fuzz vs 40% Fuzz


Author allure

More posts by allure

Join the discussion 2 Comments

  • Vic says:

    Thanks for posting this solution. I converted my .jpg images using the first command. Worked great excepted the images are now named NAME.jpg.png. Easy to fix.

    I have having trouble with the fuzz command. I have over 3,000 images. I need to use fuzz to remove artifacts around the images. I tried the command you specified (changing the name to my directory), but I keep getting errors.

    Can you please post the command for batch converting files with fuzz while make the background transparent? I would really appreciate it. I am not very good with Terminal commands. Thanks.

    • Mike Doubintchik says:

      If you are using the bulk command provided as an example in this post, this is how you would add fuzz of 20%:

      find . -type f -name "*.jpg" -print0 | while IFS= read -r -d $'\0' file; do convert -verbose "$file" -fuzz 20% -transparent white "$file.png"; done

Leave a Reply

Designed by

best down free | web phu nu so | toc dep 2017