Skip to content

How to use svgelements to calculate the correct svg viewBox #243

Description

@Emasoft

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions