Skip to content

Conversation

@Ant-Throw-Pology
Copy link

By "certain SVGs", I mean ones without width or height attributes and instead just doing viewBox or something else. Previously, my SVGs (square) would always show up as 300x150 and would have extra transparent padding on the sides. This fixes that, so that the images would at least have the right aspect ratio, even if the dimensions aren't correct. The way I did this is to use HTMLImageElement.naturalWidth and naturalHeight - letting the browser do all the complicated work with the standards. (this means that the SVG-to-PNG tool can technically resize other image types if the accepted file types are changed)

"Better data handling" is using blob: URLs instead of data: URLs everywhere possible, so we're not passing around massive strings with file contents, instead we're just using references to Blobs, and those Blobs hold the data outside of JavaScript. Additionally, there were some blob: URLs already being used (with SVG content) but not being freed with URL.revokeObjectURL, so I added some useEffect calls to clean those up.

No visual changes, this is purely logic. Except for the results being the correct aspect ratio.

Please make sure you do the following before filing your PR:

  • Provide a video or screenshots of any visual changes made
  • Run pnpm run check and make sure everything passes

@vercel
Copy link

vercel bot commented Jul 3, 2025

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

Name Status Preview Comments Updated (UTC)
quickpic ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 3, 2025 1:39am

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.

1 participant