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

User-unfriendly for "WIDTHxHEIGHT" usage; --version doesn't work #119

Open
Quuxplusone opened this issue May 23, 2024 · 0 comments
Open

Comments

@Quuxplusone
Copy link

I got here from https://stackoverflow.com/a/26048343/1424877 , looking for a way to convert SVG to any-format-I-could-upload-to-StackExchange. At first I tried this:

cd /tmp
cat >circles.svg <<EOF
<svg xmlns="http://www.w3.org/2000/svg" width="100%" viewBox="-3 -3 6 6" style="background-color: white">
  <circle fill="none" stroke-width="0.01" stroke="#000" cx="0" cy="0" r="1"/>
  <text x="0" y="0" text-anchor="middle" text-align="center" font-size="0.096774">3351747005653424648383741138532</text>
  <circle fill="none" stroke-width="0.01" stroke="#000" cx="1.95643" cy="-0" r="0.956433"/>
  <text x="1.95643" y="-0" text-anchor="middle" text-align="center" font-size="0.092558">3205723049598255148555654977125</text>
  <circle fill="none" stroke-width="0.01" stroke="#000" cx="1.01844" cy="-1.51817" r="0.828134"/>
  <text x="1.01844" y="-1.51817" text-anchor="middle" text-align="center" font-size="0.080142">2775693993058987197622141299968</text>
  <circle fill="none" stroke-width="0.01" stroke="#000" cx="-0.618734" cy="-1.71212" r="0.820489"/>
  <text x="-0.618734" y="-1.71212" text-anchor="middle" text-align="center" font-size="0.079402">2750071286250985696293256343360</text>
  <circle fill="none" stroke-width="0.01" stroke="#000" cx="-1.68589" cy="-0.534629" r="0.768634"/>
  <text x="-1.68589" y="-0.534629" text-anchor="middle" text-align="center" font-size="0.074384">2576265167388890063586881775735</text>
  <circle fill="none" stroke-width="0.01" stroke="#000" cx="-1.43584" cy="0.915451" r="0.702848"/>
  <text x="-1.43584" y="0.915451" text-anchor="middle" text-align="center" font-size="0.068018">2355770023351368908545664347968</text>
  <circle fill="none" stroke-width="0.01" stroke="#000" cx="-0.266628" cy="1.66451" r="0.68573"/>
  <text x="-0.266628" y="1.66451" text-anchor="middle" text-align="center" font-size="0.066361">2298393837394654407377433698465</text>
  <circle fill="none" stroke-width="0.01" stroke="#000" cx="1.0144" cy="1.29737" r="0.646874"/>
  <text x="1.0144" y="1.29737" text-anchor="middle" text-align="center" font-size="0.062601">2168159590729803674819757284343</text>
</svg>
EOF
svgexport circles.svg output.png 400x400

svgexport prints:

$ svgexport circles.svg output.png 400x400
/private/tmp/circles.svg /private/tmp/output.png png 100% 1x -3:-3:6:6 6:6

$ file output.png
output.png: PNG image data, 6 x 6, 8-bit/color RGBA, non-interlaced

That makes an unusably small image! At first I thought svgexport simply couldn't handle this file, and came here to report that bug. But eventually, I realized that I was supposed to write 400:400, not 400x400. And that made it work fine.

$ svgexport circles.svg output.png 400:400
/private/tmp/circles.svg /private/tmp/output.png png 100% 66.66666666666667x -3:-3:6:6 400:400

$ file output.png
output.png: PNG image data, 400 x 400, 8-bit/color RGBA, non-interlaced

So my feature request is: It would be useful if svgexport would recognize failed attempts at the required WIDTH:HEIGHT syntax, and give a useful error message — or simply support the WIDTHxHEIGHT syntax as an alternative! Anything that makes it more of a drop-in replacement for ImageMagick convert would be fantastic.

The StackExchange examples lead me to believe that you accept 2x as a synonym for what ImageMagick calls 200%, and that you probably don't have any equivalent of ImageMagick's 100x or x100 (i.e. specifying just the width or just the height). I don't know if you can really do anything to help with those use-cases, without breaking existing use-cases (e.g. it would be good for 100x to mean "width 100, height proportional" just like ImageMagick, but it would probably be bad for your existing users if 10x stopped meaning "scale by 1000%," so I don't think you can win either way on that one.)


This bug report relates to svgexport version "Invalid usage!":

$ svgexport --version
Error: Invalid usage!
$ svgexport -v
Error: Invalid usage!

so I hope you can figure it out from that. 😛

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

1 participant