133

I have a project I have been working on (an image) within GIMP and I would like to export it as an SVG. Is this possible, or am I going to have to stick with exporting multiple sizes of an image?

I know GIMP can read SVGs, but can it export them?

Flyk
  • 1,480
  • 3
  • 18
  • 24

6 Answers6

150

GIMP v2.8 does not natively export bitmaps to SVG files. There used to be a plugin to do so but this project apparently is discontinued. We could import an image as a bitmap object to Inkscape Install inkscape and save it as an SVG file. The image will then remain a bitmap file, i.e. it will get aliasing artifacts on scaling (see below).

But Inkscape can do even more. We can import the bitmaps we had already put so much work in to Inkscape and convert them with a few mouse clicks to nice vector graphics.

Here is how to do that:

  1. Open Inkscape.

  2. Choose "File - Import" to import a bitmap file.

  3. Choose to "embed" the image.

  4. Select the image with the select tool ().

  5. Select Path - Trace Bitmap... for settings (below shown for 2 colors = "Scans" ):

    enter image description here

  6. Select "Update" for a preview until settings are fine.

  7. Start tracing with "OK".

Now a vectorized image of your original bitmap will be seen on top of the bitmap. We can resize or move this newly created object, delete the original image, or choose to "Object - Ungroup" in case we need to adapt shapes or colour of sub-object created.

  1. If necessary, reduce size of the vectorized image (hold down CTRL to lock ratio), so that it fits on the page. Otherwise it may appear "cropped" when viewed.
  2. Use "File - Save As" to save your file in SVG format.

The advantage of a vector graphic can most rapidly be seen when we increase its size. Shown below was zooming to 2500%. Top is the original bitmap, bottom is the vectorized object:

enter image description here
This image and object was created from your original from chat

Takkat
  • 144,580
29

Even though Gimp is not a vector program, you can actually export single paths as SVG file with the Export Path menu item.

Here is a photo tutorial that explains in detail how to do it.

Suzana
  • 421
14

GIMP is a raster graphics editor application. SVG is a form of vector graphics. If you want to edit SVG files, you should install the inkscape package and use Inkscape instead. Also, beware that SVG is not totally "scalable" in the sense that you will get a good image at every size you scale to, so depending on what you are creating with it, you may need to draw different sizes of the image, with different amounts of detail, so that the images will look good at those sizes. Icons for an application, for example, do need to be drawn at multiple sizes, whether they are drawn as raster or vector images.

dobey
  • 41,650
9

If you need to convert a raster image to a vector image autotrace is a command line tool which does exactly that.

It's available as a debian package on Debian and Ubuntu named autotrace

An example of using it is:

autotrace input.jpg --output-file output.svg --output-format svg

Update: I've also had success with potrace where autotrace was having trouble.

Tully
  • 1,931
  • 1
  • 15
  • 11
1

potrace is the tool for that. You can process them bulk, but first you have to convert the images to monochrome:

ls ./p*.jpg | xargs -L1 -I {}  convert -monochrome {} {}.bmp
ls -1 ./*.bmp | xargs -L1 -I {} potrace {} -r 300 -b svg -o {}.svg

install:

sudo apt install potrace
1

Well, actually, you can save SVGs with GIMP. For instance, you can use this command: (gimp-vectors-export-to-file 1 "new.svg" 0)