jankovicsandras / imagetracerjs

Simple raster image tracer and vectorizer written in JavaScript.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Optimise objects in path

arshad111 opened this issue · comments

Hi @jankovicsandras ,
I have converted image to svg perfectly but in svg,there are lot of objects in path.Is there any option to avoid tiny objects from path.I have checked all options of script but i didn't find solution.

Hi,

Sorry, it's a bit unclear what your problem is.

If you got a lot of small shapes / noise, try using a bigger pathomit:

var options = { pathomit:16 };

More about options

Please post here the code you're using, so we can troubleshoot it.

I hope this is solved. If not, please reopen the issue.

Please check path from converted png to svg.There is too many tiny objects in path.I want to avoid tiny objects from path.
<path fill="#fefefd" stroke="#fefefd" opacity=".996" d="M191.5 2h53l1 1h13l1 1h22l1 1h43l1 1 17 1 11.5 4 4 8.5 1 21 1.5 1.5 11-1 1 1h15l4-1 1 1h47q1.7 2.8 8 1 8.6 1.9 13.5 7.5 6.7 8.3 9 21l1 47q-10.6 46.9-39.5 75.5-15.1 12.4-35 20l-24 5q-9.2-.8-14.5 1l-3 26.5-4 16q-7.1 14.9-19.5 24.5-19.6 17.2-47.5 25l1 5.5v15l1 2q-2.5 1.5-1 7l2 8 4.5 4.5q35.3 26.3 66 57h1.5l10 14.5 3 10v5q-1.6 7-6.5 10.5l-10 4-39 1-1-1h-15l-1-1-70-1-1 1h-14l-1-1h-33l-1 1h-22l-1 1h-24l-1-1-21-1-11-3-5.5-3.5-2-9v-8l9-16 26.5-28.5 42-37 8.5-5.5 2-8 1-22-33.5-14.5q-14.9-8.1-25.5-20.5l-8-11-5-12-7-29.5H77.5l-9-2Q49 215 37 199.5l-21-31-10-26-2-11v-9l-1-1-1-46 3-17q3.3-7.7 9.5-12.5l13-5 17-3 22-1 1-1H87q-2-17.7 8.5-24l11-4 13-1 1-1 26-1 1-1h17l1-1h25l1-1zM160 10l-1 1h-33l-1 1h-17l-2 1-3 3-2 6v21l2 10v9l1 1 1 43 1 1v20l1 1v65l1 1v12l1 1 1 15 4 20 6 14 7 10q26 27 66 40l-3 7v5l-3 12v7l-3 11v6l-59 47q-16 12-25 32-1 7 2 11l3 2 8 3h24l1 1 5-2h14l9-2h96l1 1 3-1 3 1h35l1 1h13l1 1h35l9-3 5-7-4-12-15-19-22-21-34-23-9-8-3-2-2-1q1-5-1-6v-34l-1-2q-1-5-7-4l-5 6 1 3v15l-1 5v2l1 1v13l3 5q1 4-1 6l11 15q20 17 36 38l6 3v1l-19-2-1-1h-9l-1-1-3 1-1-1h-60l-3 1h-6l-2-1h-40l-9 2h-8l-15 4-20 2-1 1h-3l7-8q2 1 1-1l62-51q5-4 7-11v-7l5-27q1-9-1-12l3 1h41l1-1 27-2 27-8q13-6 24-15 11-10 18-23l7-22 1-15 1-1 1-25 1-1 1-32 1-1v-29l1-1-1-52-1-1 1-4-1-5V47l-1-1V27l1-1q1-7-2-9l-9-6h-9l-1 1-3-1-4 1-3-1h-58l-1-1H164l-1 1-3-1zM67 44l-1 1H33q-2 3-7 1l-7 3q-7 5-9 14L7 77v9l-1 1v29l1 1 2 17 7 24 13 22q23 28 68 36l6-1 2-3-1-6-6-4-10-1-15-5-15-8-10-8-8-7-12-20-6-21-2-11v-9l-1-1 1-29 1-1v-8l3-10 5-4 5-1h24l1-1 37-1 3-4-1-4-4-4H77l-1 1-9-1zm337 3-1 1h-32l-1 1-2-1-8 1q-4 1-3 8l8 4h36l1-1h15l1 1 3-1 3 1 24 1 3 1 2 7v27l-5 28-8 26-11 17q-14 14-32 23l-26 7-14 1-4 6 1 4 7 3h7l10-2 22-6q16-7 29-18 16-12 24-32l10-35 3-17V91l1-1V73l-5-16q-4-7-12-8l-17-1-1-1h-28zM61 63l-1 1H42l-5 2-6 8-2 9v40l2 11 9 22 6 8q11 12 26 21l8 4 14 4 4-1 3-4-1-5-2-3q-12-1-19-6l-14-10q-15-12-21-32l-1-5V79l2-2q6 2 8-1h41l2-1 2-3v-3l-2-4-11-2H61zm303 3-2 1q-4 1-3 8l5 3 26 1 1 1h10l1 1h26l4 3v15l-5 27q-4 16-13 28l-9 9-23 13-11 3h-8l-4 2q-4 1-3 8l7 4 11-1 18-6 11-6 16-12 9-11 9-19 5-18 2-10v-7l1-1V78l-2-4-3-4-10-2h-31l-1-1h-11l-1-1h-22zM87 80l-1 1H75l-1 1H57l-6 4v6l2 6v20l1 1 1 11 4 14 6 10 11 9q10 6 24 9v-41l-1-1v-11l-1-1v-10l-1-1V96l-1-1V82l-1-2h-8zm277 5v17l-1 1v10l-1 1-1 27-1 1v30l15-5 23-13 10-11 11-25 4-13V90l-1-3-8-2q-5-1-6 1h-25l-1-1h-18z"/>

This path is not created with ImageTracer. ImageTracer (all versions) uses rgb() color strings, not hex e.g. #fefefd, and has only M, L and Q commands in the d="" string, etc.

You are probably using another software, not ImageTracer.

Yes its use rgb() colors.I am compressing the svg after ImageTrace so its making hex. I will remove compressing code.
But i want to make svg with small size or compress svg.Is there any solution?

ImageTracer can't compress SVG and there's no advanced optimization built-in.

It's possible to process tracedata before rendering to SVG, and it's possible to simplify paths, which might help. Please look at Issue #25.

I recommend searching the web for "SVG compress" or similar, but I'm not familiar with any SVG compressors.

SVG as a file format is based on the verbose XML format and not optimized for file size.