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

Enforce width/height arguments to be respected #779

Open
condemil opened this issue Jun 15, 2024 · 5 comments
Open

Enforce width/height arguments to be respected #779

condemil opened this issue Jun 15, 2024 · 5 comments

Comments

@condemil
Copy link

condemil commented Jun 15, 2024

Use-case: The SVG icon has size 20x30, the online service expects uploaded icon to be PNG with size 64x64px.

Current behavior: The width/height arguments is not respected and work more like a recommendation:

$ resvg --width 64 --height 64 in.svg out.png
$ file out.png
out.png: PNG image data, 43 x 64, 8-bit/color RGBA, non-interlaced

Expected result: The width/height arguments define exact image size. Icon is centered in the resulted image.

Example:

<svg width="20" height="30" viewBox="0 0 20 30" xmlns="http://www.w3.org/2000/svg">
  <circle cx="10" cy="15" r="5" fill="tomato"/>
</svg>
@RazrFalcon
Copy link
Owner

RazrFalcon commented Jun 15, 2024

--width/--height are not recommendations, they define the maximum size preserving the aspect ratio.

What output do you expect? Cropped image? Stretched image? Centered image?

@condemil
Copy link
Author

condemil commented Jun 16, 2024

Centered image, not cropped, not stretched. Just as you see it originally when open SVG file. I think it makes sense if you want to use the icon as avatar, or app icon for mobile apps. Or on your website as favicon / icon in manifest.json (android specific favicon).

@RazrFalcon
Copy link
Owner

Ok, will take a look.

@Vasilich
Copy link

But please leave the possibility to keep current behaviour - to use given size as maximum without adding empty space to the resulting PNG. There are also use cases for it.

@condemil
Copy link
Author

@Vasilich Depends on use-case it may be that you only need to specify either --width or --height, but not both, then it should work as you mentioned.

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

3 participants