K.Mandla's blog of Linux experiences

Howto: Vectorize images in Inkscape

I know you’re looking at it. I know because I can track links through WordPress, and two hours after I posted that last screenshot, I had double-digit clickthroughs. It is a rather interesting image, don’t you think?

Vector images like that can be more striking than an original photo, depending on the subject and the composition. That one works in particular because of the natural sun flare behind the towers, which makes an interesting gradient through the upper right of the picture.

That was built in Inkscape, and vectorizing an image like that takes only a few minutes, even at 1Ghz. If you’re running a fairly modern machine, you can probably have the entire job done in the time it takes to open a can of Fanta.

Anyway, here’s how you can do the same thing … and trust me, it’s quite simple.

First, I cropped the photo to the size I wanted for the monitor. You’re free to do that too if you like, although you’ll end up with a traced version of the photo, so it can be scaled to any size you like. Presizing does make things a little quicker though.

Here’s another image that looks quite nice when finished — these are the mountains outside Paarl, South Africa. The contrast between the sunset on the rocks and the blue in the sky and the deep greens in the foreground is going to be quite beautiful.

You’re free to download that one and experiment with it, if you like. It’s shot at 1600×1200, just so you know.

The first thing I do — and of course, there are probably plenty of ways to do this, so tell me if you have a better method — is to open Inkscape and plop that image down in the center. From a blank page, click on File > Import bitmap, and select your photo. It should be impaled on the document, in a rather haphazard fashion.

If you presized your image like I did, the next step is easy — fitting the document to the image (or vice-versa really). Open the Document Properties dialogue with File > Document Properties.

See the button marked “Fit page to selection”? Tap it and the job is done. If your button is disabled, try clicking on the image first. If everything goes right, the document (the white square behind your photo) will snap to the size of the picture, which is what we want.

Now let’s convert this thing. Click on Path > Trace Bitmap. You should get a new dialogue that looks like this:

This is where the magic happens. There is an impressive number of options available to you here, and you could fiddle with this all day before finding the absolute-primo settings for your photo. In this case, I’m just going to show you the ones that work for this photo. Feel free to experiment with it, and see if you get something better.

Enable “Colors,” set the Scans to 16 and click on “Remove background.” Everything else you can leave the same.

“Colors” gives us a color image, but grayscale is an option too. Sixteen scans gives us a fuller array of colors, and “Remove background” will dump the photo from the page when the conversion is done. It just saves us the step. I recommend keeping “Stack scans” enabled, because disabling it leaves white gaps in some places. Yuck.

Now click “Update.”

That gives us a preview of the image, before it’s converted. It’s a good idea to try it, just to make sure your vectorized version isn’t going to look like crud.

When it looks like you want, click OK and photo will be transmogrified. Time taken can be anywhere from a dozen seconds for an 800×600 image at 1Ghz, or a minute or two for 1600×1200. Be patient.

Here’s the finished image, still in Inkscape.

From here it’s a simple matter of exporting it as another bitmap. (If your wallpaper manager can handle a vector image — I think Gnome can — then you can just save the file and be done.) Click on File > Export bitmap and you’ll get this dialogue.

Again, you have lots of options there, but I precropped my image and so I just press OK and it’s done. Set your background however you like, using feh or whatever; here’s the completed product.

Take the time to experiment with the photos you like, and see if you can come up with better settings or new ways of doing this. And if you do, let me know. I love little tips like that.😀

Edit, 2009-12-17: A note of thanks to strongman2, who e-mailed this one to share. The original photo is from Wikipedia, here. Cheers!

Edit, 2010-04-09: Another submission, this time from an e-mail that asked not to be named.😦 Original is here.

Post navigation

18 thoughts on “Howto: Vectorize images in Inkscape”

Ha, I sure was one of these – refreshed a few times this morning. I wish the weekend wasn’t so busy so that I can try your idea.

Back on refreshing , I do find your Arch Openbox desktops quite interesting. The best so far is the yellowish/ radioactive one, fluxbox but forgot if it was Arch or something else🙂 … it might be a good idea if you could add and archive somewhere here with those too.

I am currently trying to free some time to get my brand new company laptop HP with eihter CrunchBang, Arch (but that’s too ambitious on my time for now) – an idea largely inspired by what I ‘ve read here about your experience.