Reputation: 7135
I have requirement to convert TIFF or PNG or JPEG to SVG. Is it possible to convert to SVG. By converting the PNG/TIFF/JPEG to SVG, is there any chance to reduce the size?
Upvotes: 4
Views: 15255
Reputation: 196
Imagetracer is a free and open source (Public Domain) library and application which might be useful. Disclaimer: I made this.
Get ImageTracer.jar from
https://github.com/jankovicsandras/imagetracerjava
then you can use it from the CLI like this:
java -jar ImageTracer.jar input.png outfilename output.svg ltres 1 qtres 1 pathomit 16 colorsampling 1 numberofcolors 4 mincolorratio 0.02 colorquantcycles 3 scale 0.5 simplifytolerance 0 roundcoords 0 desc 0 blurradius 5 blurdelta 20
to get a posterized SVG from the input image, which is also scaled down to half the original size.
Raster to vector conversion does not generally reduce the file size by itself, especially with SVG output, because SVG is a verbose XML based text format without compression. But this is very dependent on the input image: a simple black and white logo with several megapixels resolution saved as BMP might be reduced from megabytes to kilobytes, but a colorful JPEG photo might go from tens of kilobytes to megabytes of SVG output.
You can test this also with Inkscape (or Potrace): the result SVG is usually bigger than the input image.
Upvotes: 3
Reputation: 60976
Do you want to wrap your raster images in an SVG container, or do you want to trace the rasters to vectors? If the latter then it's not a simple problem, but you can use a tracing library to do this. There are no guarantees that the file size will be reduced.
Upvotes: 0
Reputation: 121649
Take a look at Batik:
http://xmlgraphics.apache.org/batik/
It sounds like it should probably meet at least most of your requirements. If there's some format Batik doesn't support, you can always get an additional library to read it into some "standard" bitmap format, then use Batik to convert it to SVG.
Upvotes: 1