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

Cleanup viewBox feature request #961

Open
josephfarina opened this issue May 17, 2018 · 1 comment
Open

Cleanup viewBox feature request #961

josephfarina opened this issue May 17, 2018 · 1 comment

Comments

@josephfarina
Copy link

I would like to propose a feature called something like: simplifyViewbox that updates the viewBox attribute AND all the child elements. I am more than happy to submit a PR to this. I just wanted to see if there was any interest / get some insight into the value of this request.

The use case for this is if you have a really ugly SVG file like:

<!-- This is very unreadable -->
<svg viewBox="0 0 70591.91181 35296.6681">
  <rect x="11294.48" y=" 3529.525" width="42354.3" height="28237.334" />
</svg>

<!-- This is essentially the equivalent to the above one, but easily editable by hand -->
<svg viewBox="0 0 500 250"> 
  <rect x="80" y="25" width="300" height="200" />
</svg>

I think the API would allow the user to specify a height AND/OR width value.

  • If both are specified then that would be destructive to the aspect ratio.
  • If just a height is specified then the width will be calculated based on the already existing aspect ratio.
  • If just a width is specified then it would be the opposite if just a height is specified.

Very interested in hearing any thoughts you have about this.

@GreLI
Copy link
Member

GreLI commented May 17, 2018

It's a known optimization technique, but unfortunately it's hard to automate, especially in more complex cases. E.g. how to you find these numbers? You need to scale by a certain value, but how do you know this value and that it's good, other then trying many possibilities one by one which is ineffective and slow? See #293.

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

No branches or pull requests

2 participants