I'd like to be able to crop SVG chemical structures, completely (see this question), that were created using MarvinSketch and I think I might have thought of a solution; I use MarvinSketch to create a large PNG file, then crop that using GIMP, and then convert the PNG to SVG. Hence I'd like to know if anybody knows a free software I can install (I don't like using online converters as I'm always suspicious of malware) on Ubuntu for high quality PNG->SVG conversion.

  • OK what would a code for that look like? I tried reversing the code as you said, from my knowledge (I'm a code noob). This is the code I used `#{INKSCAPE_PATH} -z -f #{Guanidine.png} -w #{width} -j -e #{Guanidine.svg} – BH2017 May 22 '14 at 7:31
  • After doing cd ~/Documents/Chem Structures/ which is the directory in which the files are. – BH2017 May 22 '14 at 7:34
  • sudo apt-get install imagemagick then save this script #!/bin/bash while [ $# -gt 0 ]; do picture=$1 png_file=echo "$picture" | sed 's/\.\w*$/.png/' /usr/bin/convert "$picture" png:"$png_file" shift done in ~/.local/share/nautilus/scripts and remember to make it executable then just right click then scrips then what ever you save this script under – zeitue May 22 '14 at 7:35
  • OK, as I said I'm a noob so you're going to have to explain that better as all I understood was sudo apt-get install imagemagick – BH2017 May 22 '14 at 7:37
  • 1
    You should nevertheless be aware that there is a fundamental difference between vector graphics like SVG and pixel graphics like PNG. Once you loose the vector information, there is no (loss free) way to restore it. So, even if you "convert" from PNG to SVG, you basically do nothing else as embedding the pixel graphics (base64 encoded) within an SVG vector graphics file. The convert command is even worse: It places a circle for every pixel of the pixel graphics, what leads to very large file sizes. I'd therefore try to directly cut the SVG file. – soulsource May 22 '14 at 13:37

So you are looking for raster to vector graphics converter. potrace & autotrace both are in Ubuntu repository. Myself I tried potrace before which gave nice results with default options. As I remember, both tools do not support compressed formats as input, only bitmap images.

See Potrace examples

Potrace: utility to transform bitmaps into vector graphics

potrace is a utility for tracing a bitmap, which means, transforming a bitmap into a smooth, scalable image. The input is a bitmap (PBM, PGM, PPM, or BMP format), and the default output is an encapsulated PostScript file (EPS). A typical use is to create EPS files from scanned data, such as company or university logos, handwritten notes, etc. The resulting image is not "jaggy" like a bitmap, but smooth. It can then be rendered at any resolution.


potrace -s inputfile

AutoTrace: bitmap to vector graphics converter

AutoTrace is a program for converting bitmaps to vector graphics. The aim of the AutoTrace project is the development of a freely-available application similar to CorelTrace or Adobe Streamline. In some aspects it is already better. Originally created as a plugin for the GIMP, AutoTrace is now a standalone program.


autotrace -output-format svg inputfile


  • man potrace
  • man autotrace
  • I ran autotrace -vector svg inputfile (after changing inputfile to fenfluramine.png) and it didn't work, I also changed the output-format to svg didn't work. I have installed it. – BH2017 May 23 '14 at 1:40
  • I ran potrace -s inputfile (with the inputfile being fenfluramine.png again) and it gave me this error: potrace: /home/fusion809/Documents/Chem Structures/Fenfluramine.png: file format not recognized Possible input file formats are: pnm (pbm, pgm, ppm), bmp. – BH2017 May 23 '14 at 1:46
  • @BrentonHorne, you should create PNM or BMP image instead of PNG. both tools do not support compressed formats as input (PNG, JPEG...), only Bitmap images (PNM, BMP,...). If you can't export other then PNG then try convert them 1st to BMP. – user.dz May 23 '14 at 3:08
  • Well then you didn't answer my question. MarvinSketch can export to BMP but its background isn't transparent which is why I suggested the format PNG in the first place. It can't do PNM. – BH2017 May 23 '14 at 7:23
  • 1
    Aha, it did work. Thanks. I thought as the BMP wasn't transparent any result wouldn't be too. – BH2017 May 23 '14 at 11:05

Inkscape has got an awesome auto-tracing tool.

  1. Install Inkscape using sudo apt-get install inkscape
  2. Import your image
  3. Select your image
  4. From the menu bar, select Path -> Trace Bitmap Item
  5. Adjust the tracing parameters as needed

Check their tracing tutorial for more information.

Once you are comfortable with the tracing options. You can automate it by using CLI of Inkscape.

  • 2
    +1, Thank you. Happy to hear that Inkscape has integrated potrace functionality in the GUI as stated in the reference you mention. – user.dz Jan 3 '16 at 19:26
  • 2
    This is the correct answer as potrace does not support .png import, and it's easy to get into difficulties with transparency etc with conversions. – brianlmerritt May 4 '17 at 11:10

Use the convert command in the terminal :

For example : convert EXAMPLE.png EXAMPLE.svg

Here's some info from the manpage :

convert(1) - Linux man page


convert - convert between image formats as well as resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more.


convert [input-options] input-file [output-options] output-file

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.