Replace black/white parts of an image with ImageMagick
Replace white sections of an image with transparency:
$ convert myimage.jpg -transparent white myimage.png
If it’s not pure white, and you need a bit of extra:
$ convert myimage.jpg -fuzz 10% -transparent white myimage.png
If you want to additionally crop the image to the nontransparent portion:
$ convert myimage.jpg -fuzz 10% -transparent white -trim myimage.png