Convert any image to vector graphic ?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Rye
Posts: 158
Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789

Convert any image to vector graphic ?

Post by Rye »

Since I got some images I'd like to try and convert to vector images I'll just right out ask:

Is it possible to have Imagemagick create vector images from multiple lets say png's I have ?

Thanks for an answer in advance.
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert any image to vector graphic ?

Post by snibgo »

Sorry, no. IM can convert from vector to raster, but not raster to vector.

Inkscape can do this ("trace bitmap"), and other tools are available.
snibgo's IM pages: im.snibgo.com
Rye
Posts: 158
Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789

Re: Convert any image to vector graphic ?

Post by Rye »

Can Inkscape batchprocess images ?
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert any image to vector graphic ?

Post by snibgo »

To some degree, though it is really an interactive program. I don't know if it can trace bitmaps in batch. Potrace (http://potrace.sourceforge.net/) may be better for you.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert any image to vector graphic ?

Post by fmw42 »

Rye
Posts: 158
Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789

Re: Convert any image to vector graphic ?

Post by Rye »

Well since Potrace obviously only converts images to black and white: http://potrace.sourceforge.net/mkbitmap.html

I shall try that even if it means I have to use my linux environment.
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert any image to vector graphic ?

Post by snibgo »

Potrace just finds edges and makes paths. You can use IM to do colour-separation first, then edit the SVG output from Potrace as appropriate.

If you supply a sample image and what you are trying to do with it, advice can be more specific.
snibgo's IM pages: im.snibgo.com
Rye
Posts: 158
Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789

Re: Convert any image to vector graphic ?

Post by Rye »

According to this http://stackoverflow.com/questions/1132 ... magemagick Imagemagick can do it with autotrace etc. as support app ?

Image to test:

Image
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert any image to vector graphic ?

Post by snibgo »

And what vectors do you want? If you want a load of small circles, negate the image first (eg with potrace "-i" or IM "-negate"). In potrace, you'll want "-t 0" to capture even the smallest stars. You'll probably also want to play with -k, --fillcolor and others. See potrace documentation.
snibgo's IM pages: im.snibgo.com
Rye
Posts: 158
Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789

Re: Convert any image to vector graphic ?

Post by Rye »

However I need a colored vector image.

Can Potrace do this ?
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert any image to vector graphic ?

Post by fmw42 »

I do not think a raster image can be effectively vectorized? You will get millions of vectors if not a fault because there are too many. You probably cannot vectorize such a raster image, only ones with a few constant color regions. But I will defer to those others who know more about vectorizing.
Last edited by fmw42 on 2013-08-11T18:02:44-07:00, edited 1 time in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert any image to vector graphic ?

Post by snibgo »

Potrace won't decide on the colours for the vectors.
snibgo's IM pages: im.snibgo.com
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Convert any image to vector graphic ?

Post by anthony »

The only effective vectorisation tool I have seen for colored images involves using vector data that is not available generally to vector images.

One example was a IFS (fractal generator) method that was never made public (tried to be commercial).
You example image for example would compress extremely well using a IFS image format, as it has a lot of fractal like information in it.

Another is the use of Diffusion Curves. which defines colors along edges, and then generated gradients from those colors.
http://maverick.inria.fr/Publications/2 ... /index.php

But no generally color images do not vectorise easilly, at least not without a lot of simplification, and color distortions.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply