You probably have already downloaded once an image with a white background, such as this one (the grey area around the logo just serves the purpose of seeing the white background).

Logo with white background
Logo with white background

For a number of reasons, one could want to have the same image with a transparent background. Luckily, ImageMagick has our back covered once more.

If you haven't already, install ImageMagick:

brew update && brew install imagemagick

With ImageMagick installed, the easiest way to remove the white background is to use the following command:

convert test.png -transparent white transparent.png

The command is very simple: we pass an input and output files and the -transparent option is used to select the color we want to make transparent which can be passed as a color name or in hex/RGB format. Of course, you should choose an output format which handles transparency, such as PNG. The input can be in any format though.

Trying this command with our image from above gives the following. This looks fine, however if we look more closely we'll see that not all white parts have been removed.

Logo with transparent background
Logo with transparent background
Close-up of the logo with transparent background
Close-up of the logo

The -fuzz option can help us here. It simply matches colors that are within x percents of the intensity of the target color. In most cases, 2% is a reasonable value.

convert test.png -fuzz 2% -transparent white transparent.png

Voilà!

Logo with transparent background
Logo
Close-up of the logo with transparent background
Close-up