Skip to content

Investigate better SVG code parsing  #49

Description

@tomayac

Maybe use https://github.com/WebReflection/linkedom for

svg = svg.replace(
'fill="#000000" stroke="none"',
`fill="rgb(${r},${g},${b})" stroke="rgb(${r},${g},${b})"${
a === '255'
? ''
: ` fill-opacity="${alpha}" stroke-opacity="${alpha}"`
} stroke-width="${params.strokeWidth}px"`,
);
const pathRegEx = /<path\s*d="([^"]+)"\/>/g;
let matches;
const shortPaths = [];
while ((matches = pathRegEx.exec(svg)) !== null) {
const path = matches[1];
if (path.split(' ').length < params.minPathSegments) {
shortPaths.push(matches[0]);
}
}
shortPaths.forEach((path) => {
svg = svg.replace(path, '');
});
.

Activity

  1. self-assigned this
    on Jan 20, 2022
  2. removed their assignment
    on Aug 5, 2022
  3. xwiz commented on Aug 24, 2022

    @xwiz

    Well done, really great job... I'm interested in improving the performance/speed of this tool, do you have any pointers where I should start from?

  4. tomayac commented on Aug 24, 2022

    @tomayac
    OwnerAuthor

    The present issue is purely about replacing string-based replacement with proper DOM parsing.

    If you are interested in improving the performance: see tomayac/esm-potrace-wasm#8. The latest version of esm-potrace-wasm is capable of dealing with color, but fails on too large inputs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions