We ❤️ Open Source

A community education resource

2 min read

How to create a holiday card with open source tools

Easily remove photo backgrounds this holiday season using rembg.

This year, there are several open source tools available that can help you create a personalized holiday card. If you have a great photo of your family or grandchildren but want to change the background—perhaps to fit a festive winter scene—you can use a Python module called rembg to remove and replace the background. Here’s how you can get started with it.

Getting started

First, set up a Python virtual environment to keep things organized. I created a directory named rembg with the following command:

$ mkdir rembg 

Next, set up the virtual environment:

python3 -m venv /home/don/rembg

Then activate the environment with this command:

source /home/don/rembg/bin/activate

Now, you’re ready to install the necessary dependencies. First, install rembg:

pip3 install rembg

To use rembg from the command line, install the command-line interface as well:

pip3 install "rembg[cli]"

You’ll also need onnxruntime, which acts as a machine learning accelerator:

pip3 install onnxruntime

Removing the background

Now, let’s get to the fun part—removing the background from your image. I’ve selected a recent photo of my wife and I, taken in the fall. While I love the image, I’d like to give it a more festive backdrop.

Family photo for editing
Photo by Sissy Horch

Make sure your image is in the rembg folder, and then run this command to remove the background:

rembg i grandparents.jpg grandparents_no_bg.jpg

In this command, the i flag tells rembg to process the file. I also renamed the output file (grandparents_no_bg.jpg) to keep the original image in case I want to use it again. After running the command, you should see that the background has been removed from your image.

Family photo for editing with background removed

Adding a new background

Once the background is removed, you can get creative. For my card, I used InkScape to design a festive background. I added some holiday lettering and a Poinsettia image I downloaded from OpenClipart.org. The completed card turned out beautifully!

Finished holiday card

Both rembg and onnxruntime are open source with an MIT License.

More from We Love Open Source

This article is adapted from “Transforming family photos into festive holiday cards with AI” by Don Watkins, and is republished with permission from the author.

About the Author

I am Don Watkins, a free and open source software (FOSS) advocate.

Read Don's Full Bio

The opinions expressed on this website are those of each author, not of the author's employer or All Things Open/We Love Open Source.

Want to contribute your open source content?

Contribute to We ❤️ Open Source

Help educate our community by contributing a blog post, tutorial, or how-to.

This year we're hosting two world-class events!

Join us for AllThingsOpen.ai, March 17-18, and All Things Open 2025, October 12-14.

Open Source Meetups

We host some of the most active open source meetups in the U.S. Get more info and RSVP to an upcoming event.