How to Use the Bitmap Trace Tool In Inkscape

In an earlier tutorial we showed how to create custom gradients in Gimp and use them to decorate butterfly wings. This tutorial follows on from that by showing how to take a photo of a butterfly then use the bitmap trace tool in Inkscape to turn the wing into an SVG graphic. As anyone who has used Inkscape before will know, the advantage of this is that the SVG graphic can be exported at any chosen size without losing image quality.

As well as showing how to use the trace bitmap tool in Inkscape, this tutorial will first prepare the photo in Gimp, then once the bitmap has been traced it will be modified, exported from Inkscape and then tweaked again in Gimp so it is ready to use in other graphics.

This may seem a complex tutorial but each step is very quick and simple and at the end you will have a butterfly image (or in fact any other image) you can use in numerous ways. Click each image to view full size if you need to.

How to Use the Bitmap Trace Tool In Inkscape

1/ This is the image we'll start with, so first of all open it in Gimp.

2/ To make it easier to use the trace bitmap tool in Inkscape we'll make the photo monochrome. It is possible to simply open the photo in Inkscape and apply the trace bitmap tool, but a little manipulation in Gimp to begin with lets us control the quality and appearance of the final result.

Removing a lot of unwanted detail from the image is what we want to do here, so firstly select Colors > Desaturate > Color to Gray.

3/ This is the desaturated image.

4/ To remove unwanted detail we'll use the Curves tool, so select Colors > Curves.

5/ The above window will open. Grab a point on the diagonal line to lighten or darken sections of the image. The extent this needs to be done will be different for every image, but the above image shows the settings used here.

6/ This is how the image was changed and is very close to what we want. There are still a few grey patches around the butterfly which can be painted out, although they're unlikely to show after the image has been traced in Inkscape.

7/ To create a more symmetrical appearance to the butterfly we just need half of the original image which we can later duplicate, invert it horizontally and then join to the other half.

For this reason whilst both the antennas of the butterfly are weak all we need do here is work on the right antenna.

Using Ctrl and the mouse wheel we have zoomed in on the head of the butterfly so we get a better view.

Create a transparent layer and select the Paths tool from the toolbox. left mouse click at the start of the antenna, click again at any sharp angle, then at the end. If there's a curve in the antenna hit Ctrl and click in the middle of the curve to add a node. Now drag the new node so the path curves to match the antenna.

In the lower half of the Toolbox panel hit the Stroke Path button.

8/ The above window will open. Select the width of the antenna line then hit the Stroke button when ready.

9/ This is the result of hitting the Stroke button.

10/ To create a more natural rounded end to the antenna, on a new transparent layer using the Ellipse tool (2nd from the top left) in the Toolbox, create a small elliptical shape. Fill it with black, then using the Rotate  and Move tools position it at the end of the antenna.

Now merge all the layers. A less destructive way would be to right click on one of the layers and from the drop down list select New from Visible. This will create a new layer consisting of all the visible layers. Your original layers will be intact.

11/ We now need to remove half of the image, so with the Rectangle Select tool (top left) from the Toolbox panel, drag a rectangle around the half we want to keep. Here its the right half. Be precise with the placing of the rectangle. Once positioned the edges of the rectangle can be adjusted by dragging them.

12/ Hit Image > Crop to Selection and the unwanted section of the image will be removed. Now export the image from Gimp, saving it as a PNG file rather than a JPeg.

Tracing The Bitmap In Inkscape

13/ Open the image from Gimp in Inkscape. You'll see a window similar to the above. Make sure the options are the same as here then click OK.

14/ You may need to make the page fit the Inkscape window by hitting 5 on your keyboard.

15/ With the image selected go to Path > Trace Bitmap (Shift > Alt >B).

16/ This panel will now appear to the top right of Inkscape. There are a number of options for tracing bitmaps, but the above settings should work well for this image. The best way to find out what effects the settings will have is to play around with them, remembering that you can always make use of the undo function (Ctrl > Z).

If you don't see a preview of the traced bitmap hit the Update button. When you're ready hit OK.

17/ The traced bitmap will appear directly on top of the original image, so you'll have to move it to see the difference between them both. If you're unhappy with the result, select the original image then tweak the settings in the Trace Bitmap window and hit OK again when you're ready.

18/ When you have a traced bitmap you're happy with the original image can be removed.

19/ There will probably be some missing details from the butterfly wing, so we'll now fix that. The original photo will be used as a guide so import it into Inkscape then move it below the bitmap by hitting Object > Lower (Page Down).

The image may also need to be adjusted to match the size of the bitmap by dragging the arrows at its corners and edges.

20/ To make it easier to distinguish between the bitmap and photo, the opacity of the photo has been lowered using the slider to the right (highlighted in red).

 Using the Bezier Tool

21/ Using the Bezier tool (highlighted in blue to the left) the veins of the wings can be drawn in. click at the start of the line you want to draw, then double click at the end.

22/ To the right of Inkscape there should be the Fill and Stroke panel. If you don't see it, hit Shift > Ctrl > F. Under the Stroke style tab the width of the line created with the bezier tool can be adjusted. The default setting is millimetres so its usually best to change this to pixels (px).

There are also options to choose if the end of a line should be flat or curved.

23/ In the image above a bezier line has been added to part of the wing that has a straight section as well as a curved section. To change direction in a line, click at the position you want the line to begin, which will add a node. Thenclick at the part of the line a new direction is needed.

The easiest way to create a curve within a bezier line is to click at the start of the line, then double click at the end.  Now select the Edit Paths tool (2nd from the top left highlighted in blue), then double click in the middle of where you want a curve. This will add a node to the middle of the line.

The tools highlighted in red in the above image can be applied to an active node. After adding the node to the middle of a line, select one of the node tools then drag the node. The first node tool will create a sharp angle, but the other three create curves with different features.

Once the node has been dragged the line will curve and handles will appear on the node. These handles can be seen in the above image and can be moved to adjust the curve..

24/ This image shows the wing with the veins drawn in.

25/ The background image is no longer needed so it has been removed. We're now going to duplicate this half of the butterfly.

26/ The first thing we need to do is drag the selection tool (first tool, top left, highlighted in blue) to form a box over all the elements of the image. This will select all these elements. Now select Object > Group (Ctrl > G). Now all the different elements of the image will act as one object.

Check all the parts have been selected and grouped by moving the group a little. Any parts that don't move have not been grouped. Select Edit >Undo until the grouped parts are moved back to their original position, then follow the steps to group objects.

27/ With all the parts grouped select Edit > Duplicate (Ctrl >D).

28/ We now have two wings. Use the Selection tool to move one wing to the left, then use the transform tool (highlighted in red in the above image) to flip the wing horizontally.

Export The Image From Inkscape

29/ Move both wing sections together and you have a perfectly symmetrical butterfly. The image still needs a little work however so now we'll export it from Inkscape then open it in Gimp.

30/ First select one half of the butterfly, hold down shift then select the other half. Now select File > Export PNG Image (Shift > Ctrl > E). A panel similar to the right of the above image should be visible.

There are a number of options for exporting an image from Inkscape including exporting the page or the drawing, but in this instance we'll use Selection (highlighted in blue, top right) so that only the bitmap is exported with no background etc.

In the Image size section, add the size you want your image to be.

The area highlighted in red allows you to name and save the image file to a location on your PC. Hit Export As then navigate to the location on your PC, and name the image file.

When you have finished navigating to the location for the file and naming it, the image has still not been exported from Inkscape. This sometimes confuses a few people because you'll need to hit Save in the navigating window, so its easy to think the image has been saved. For the image to actually be exported however, the Export button highlighted in Green should be clicked.

Tweaking The Image In Gimp

31/ This is the image in Gimp. The background of the butterfly is transparent, and the white is a background layer I added to highlight any blemishes.

All we really need to do to the image in Gimp is paint in any gaps we don't want. The area where the two halfs meet is an obvious example since the seam is visible, although there are also areas in the wings to fill in. Finally there are a few black spots that need erasing.

32/ This is the final touched up image ready to be used on other projects.

To use the butterfly image for the tutorial on creating gradients mentioned at the top of this page you'll need to duplicate your butterfly layer then create a silhouette similar to the one above. If it isn't clear why you need this take a quick look at the tutorial by following the link above and all will become apparent.

The techniques covered in this tutorial can clearly be used for much more than creating butterfly based graphics, particularly the bitmap tracing section. Also the fundementals of using the bezier tool will become a mainstay for many budding designers as they become more familiar with Inkscape, and use it do some of the tasks it does better than other software such as Gimp. If you've enjoyed this tutorial feel free to share and to come back for more.