Go to TogaWare.com Home Page. GNU/Linux Desktop Survival Guide
by Graham Williams
Duck Duck Go


Transparent Images

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 capture more of the background of the image as transparent using -fuzz:

$ convert -transparent white -fuzz 15% orig.jpg trans.png
$ display trans.png

Support further development by purchasing the PDF version of the book.
Other online resources include the Data Science Desktop Survival Guide.
Books available on Amazon include Data Mining with Rattle and Essentials of Data Science.
Popular open source software includes rattle and wajig.
Hosted by Togaware, a pioneer of free and open source software since 1984.
Copyright © 1995-2020 Togaware Pty Ltd. Creative Commons ShareAlike V4.