GNU/Linux Desktop Survival Guide
by Graham Williams
20190303 A common requirement when working with graphics files that you want to include in a colourful document or to place on your web page is to convert its background from white to being transparent. Both GIF and PNG images support transparency but JPG does not. With a transparent background an image will often blend nicely with the web page or presentation background colour.
We can replace the white background of a JPG image with a transparent
background to create a PNG image using convert from
imagemagick. The key option is -transparent:
$ convert -transparent white orig.jpg trans.png $ display trans.png
After conversion we will want to display to image to ensure all is as expected.
If the white in the original is not pure, as is often the case, we can
introduce some fuzziness to improve the capture more of the background
of the image as transparent using -fuzz:
$ convert -transparent white -fuzz 15% orig.jpg trans.png $ display trans.png