128

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?

2
  • Gimp is like a partially opensource project, since the XCF file format is not a widely used open standard and thus becomes something of a proprietary format. That said, it is impossible for the editor of well-designed works carried out in GIMP to export his work to SVG, for example, or other possible formats to work in another application in a simple way.
    – kokbira
    Mar 1, 2023 at 11:33
  • The SVG file is the first open format we think of because it supports layers, and sometimes we don't care about an SVG that is 100% vector if the export format maintains the position and format of layer elements and editable texts.
    – kokbira
    Mar 1, 2023 at 11:45

6 Answers 6

147

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

6
  • 1
    Thanks for the nice overview. You could improve your answer by giving an answer to the original question. Photoshop CC can supposedly export SVG images, so can Gimp do it?
    – daniels
    Nov 5, 2015 at 9:56
  • 1
    @daniels: Gimp can be made to export a bitmap embedded in an SVG with a plugin but this (like PS btw) will not trace a bitmap to vector. For this you'd need Inkscape or an other tracer, e.g. autotrace. For the latter there is a Trace gimp plugin which I have not tested.
    – Takkat
    Nov 5, 2015 at 10:08
  • @Takkat, the gimpToSVG extension does not exist anymore
    – kokbira
    Jun 12, 2017 at 19:49
  • @Takkat, where? On github.com/jabiertxof/gimpToSVG you can see only a "moved to GitLab" info. On given GitLab link, gitlab.com/jabiertxof/gimpToSVG, you cannot download, and to see code "You need permission. Want to see the data? Please ask an administrator for access.", but where?
    – kokbira
    Jun 13, 2017 at 11:22
  • @Takkat, trying git.exe pull -v --progress "https://gitlab.com/jabiertxof/gimpToSVG/" returns "remote: You are not allowed to download code from this project. / fatal: unable to access 'gitlab.com/jabiertxof/gimpToSVG.git': The requested URL returned error: 403 / git did not exit cleanly (exit code 1) (21075 ms @ 13/06/2017 08:29:28)"
    – kokbira
    Jun 13, 2017 at 11:31
26

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.

1
  • 1
    This is such an important feature to be aware of. Thanks for sharing!
    – k4rtik
    Mar 1, 2022 at 14:58
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.

2
  • You can use a single SVG and just change the size by setting the dimensions in CSS. I do it all the time… you don't need to draw the image at multiple sizes (obviously you wrote your comment seven year ago… not aiming at you, but just for anyone else coming along).
    – Andy Swift
    Jun 13, 2020 at 20:52
  • @AndrewSwift My comments about the scalability and multiple sizes are still valid. A 16x16 area of pixels cannot contain all the detail one might put into a significantly larger image. SVG is not perfectly scalable through an infinite range. Therefore, multiple images may need to be drawn to handle multiple range sets, so that the image can be displayed with appropriate detail in those ranges. This mostly applies to things that need to be displayed at varying widely different ranges, such as icons.
    – dobey
    Jun 15, 2020 at 14:39
8

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.

5
  • 4
    I tried with two images and it gives Read Error and the other [7B]pT[F5]: invalid chunk type... they are valid png btw
    – Adrian
    Jul 5, 2015 at 1:38
  • 1
    @Adrian, Shouldn't the command be autotrace input.png --output-file output.svg --output-format svg instead? Mar 28, 2016 at 10:46
  • @Adrian I got the same, but just checked the website and I think it doesn't support PNG. I tried PBM and then it worked! Oct 18, 2016 at 16:09
  • 1
    It didn't recognize png, so I converted it to jpg. It produced an almost 6MB svg from a 200KB jpg. The reason: it basically takes every individual pixel as a little square. Not usable in this form.
    – Csaba Toth
    Feb 12, 2017 at 18:07
  • 2
    For future readers, it might be worth noting that InkScape (noted in the selected answer) currently uses Potrace spinoff for its "Trace Bitmap" tool. So, there should not be a significant difference between the outputs of potrace and the InkScape tracing tool.
    – Spencer D
    May 8, 2017 at 0:46
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
  • 1
    This worked (for ls ./*.png). Yet I to restore the original colour, I copied the output.bmp.svg to edit.svg and changed fill="#000000" to fill="#000050" inside that edit.svg file and save+reopen it in an image viewer. the 050 was not a lucky guess, 07000 also restored a color that somewhat resembled the original color.
    – a.t.
    Jul 1, 2021 at 0:32
0

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

1
  • Can you explain a bit more what you mean and how to do that. Is this a CLI tool?? I have no such command.
    – pLumo
    Oct 27, 2022 at 6:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .