jankovicsandras / imagetracerjs

Simple raster image tracer and vectorizer written in JavaScript.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Node Script does not converted perfect SVG (looks different compare to original file)

arshad111 opened this issue · comments

Hi András Jankovics,

I have used nodejs script to convert png to svg.I have converted few images and its converted perfectly.But in one image it does not converted png to svg,its looks differently in svg.Please check below image.
command : node nodecli whatsapp.png outfilename whatsapp4.svg

node version:v10.19.0

png file :
whatsapp

svg file
whatsapp4

Hi,

The input PNG file is not in RGBA8888 format, but it has an indexed palette. It seems PNG.js (which is not a part of the ImageTracer project) couldn't convert it to an RGBA8888 ImageData object, so the pixel addressing is wrong.

Luckily it's very easy to fix: just convert the input PNG to RGBA8888, for example with GIMP -> Image -> Mode -> RGB .

Okay thanks @jankovicsandras.I dnt have any idea bout this.Can you please give me instruction regarding this.
Is there any way to check image is RBGA8888 format or not..if not than how to convert to RGBA8888?

Most image editors should show the color / palette format under image properties and should be able to convert. I suggested GIMP, because it's free and open source.

  1. Download and install GIMP from here
  2. Open your image and on the top menu: Image -> Mode -> RGB
  3. Save and try imagetracer again

There are many alternatives, also command line / automatic solutions, I recommend searching the web for them. See also Comparison of raster graphics editors

Thank you @jankovicsandras , i will check and let you know :)

Hi @jankovicsandras ,
Is there any option to reduce(compress) svg file size?

There are some options which can reduce the svg file size somewhat, at the cost of quality. You can experiment with these, but SVG as a file format is based on the verbose XML standard, so file size is not a priority for SVG and not in the scope of the ImageTracer project.

numberofcolors : small values get smaller files, try 2 .. 4 .. 8 maybe (default is 16)
pathomit : big values discard more paths, try 16 .. 32 ... (default is 8)
roundcoords: value 0 will result smaller files (default is 1)
ltres ; qtres : big values might get smaller files, try 2 .. 4 .. 8 ... (default is 1)