Feature Request: Keep Aspect ratio when resizing to specific width/height

Migrated from https://bugs.launchpad.net/inkscape/+bug/1795676

Steps to reproduce:

  • via the CLI convert an .svg file to a .png to certain dimensions while keeping the original aspect ratio

What happened?

  • while .png file is reduced to specified size it doesn't retain its original aspect ratio

What should have happened?

  • via some additional switch or command, .png should retain its original aspect ratio while resizing

Inkscape Version and Operating System:

  • Inkscape Version: 0.92.x (judging from the date)
  • Operating System: Windows
  • Operating System version: --

Files:

sportscar3.svg

(from http://tuxpaint.org/stamps/stamps/vehicles/auto/sportscar3.svg)

Original Bug Report:

When using command line resizing today you'd do something like this: inkscape.exe -f=myInputSvg.svg -e=myOutputFile.png -w=400 -h=400 -z

Then the resulting image will be 100% wide and 100% high which is all fine and dandy, however it can look very squeezed.

You might not want such a result, you might want keep the aspect ratio of the original svg. So a suggestion would be to add a parameter -keepAspect or -maintainAspect

Which would still make a 400x400 image however the actual drawing inside will be centered inside to 200x400 or 400x200 depending on the shape of the original svg.

This is a suggestion and something which I am in need with.

Here's what I used to export the png in the comments below: "c:\program files\inkscape\inkscape.exe" -z -f=sportscar3.svg -e=sportcar.png -w=400 -h=400

sportcar

Additional Notes:

There may possibly be a way to perform the task the reporter requests, but due to the arcane nature of Inkscape's command line processing plus the present rewrite of commands (verbs/actions) for the 1.0 release, I found no way to accomplish this.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information