Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix svg output not rendering in image editor softwares #54

Merged
merged 1 commit into from
Oct 6, 2024

Conversation

lyqht
Copy link
Owner

@lyqht lyqht commented Oct 6, 2024

Resolves #52

Description

SVG outputs don't render as intended in image editor softwares. Upon investigation, in tsayen/dom-to-image#64, it was mentioned that dom-to-image library's toSvgElement doesn't actually create a proper SVG element with paths/shapes. It simply creates a foreignObject, which is usually recognizable on web browsers. This is also why the exported SVGs render as expected on this GitHub repo's README.md.

However graphic editor softwares like InkScape, Adobe illustrator cannot recognize the SVG file format.

Hence, this PR fixes the issue by swapping the implementation for SVG output to another library, dom-to-svg. Thank you @felixfbecker for creating this library!

Below is a screenshot on InkScape after fix.

CleanShot 2024-10-06 at 16 38 19@2x


Other solutions explored that don't work

Tried SVGCode (underlying mechanism is Potrace) for retracing PNG to SVG, but it doesn't look like how it looked on web.
CleanShot 2024-10-06 at 15 09 06@2x

Tried dom-to-image-more, an enhanced version of the library, but the output SVG doesn't look like its original too.

Copy link

vercel bot commented Oct 6, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
mini-qr-code-generator ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 6, 2024 8:38am

@lyqht lyqht merged commit 4d67d5b into main Oct 6, 2024
3 checks passed
@lyqht lyqht changed the title fix svg not rendering in image editor softwares fix svg output not rendering in image editor softwares Oct 6, 2024
@lyqht lyqht deleted the fix/svg-output branch October 6, 2024 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to view exported SVG fully in Adobe Illustrator
1 participant