-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
How to use svgelements to calculate the correct svg viewBox #243
Comments
Those svgs aren't broken. The value of an svg without a viewbox is well defined. Namely it is viewed at a 1:1 value without any viewbox transformations. The spec is quite clear that is permitted and nothing is wrong with the svg since they do not actually require a viewbox. You could probably calculate the bounding box of a particular set of elements. I think .bbox(). But, that's a bit different than you'd probably want. You can't stop it from flattening all the transforms and concatenating all the matrices, that happens automatically and you can't stop it. I have a planned second project to fix that as an issue. These svgs have no matrix as far as you showed me. The correct viewbox for your svg that is essentially identical to an svg without a viewbox is actually |
I see only a white image. Where is the content? |
I want to use svgelements to fix some svg files that are generated by a program.
Those svg files are missing the viewBox:
Here is an example svg file:
https://gist.github.com/Emasoft/ccce2973465c2c0a6b165d1135efe1e1
Can svgelements compute the correct viewBox so that when displayed in the browser the above gist will shows the full image, with the right aspect ratio and no empty space?
I tried with the .bbox() method, but the values when used as viewBox values are still wrong. Only a part of the image is shown.
I read that you need to flatten the transforms concatenating all matrix, but how can I do that with svgelements?
The text was updated successfully, but these errors were encountered: