Ruby – RMagick remove white background from image and make it transparent

imageimage manipulationimagemagickrmagickruby

I need to remove the white background from this image and make the background transparent. So it's just a black tick on the transparent background exported as a png.

e.g. Turn

enter image description here

Into

enter image description here

Any ideas?

Best Answer

convert image.png -matte -fill none -fuzz 1% -opaque white result.png

Replaces anything white with transparency. The fuzz option includes anything that is almost-white.