Script to export a SVG to PNG with a certain width. IDK why the exported picture has not this size.

The issue is that if my script is correctly done, a SVG is supposed to be exported to PNG with a fixed width, the script seems to work fine, but when I check it out again on Inkscape*, it shows me the original SVG size, not the resized PNG exported picture.

Here's a folder with the script and a random SVG I'm using for testing.


*To check the size of the picture in Inkscape, we need to change the units in the top bar, and then see the numbers that shows. The screenshot shows a 14,79 cm x 9,85 cm, instead of 10,5 cm x 6,9 cm.

3 points · 2 comments · view on lemmy.world

2 Comments

AProfessional@lemmy.world · 3 pts · 2y (1 reply)

Unless you need Inkscape you can use a more simple tool like rsvg-convert.

Moshpirit@lemmy.world · 1 pts · 2y

Oh! Cool tool!! I have a doubt, though.

  • If I use rsvg-convert --width=1050mm --keep-aspect-ratio svg.svg > reduced.png, the dimensions of the picture I get are 105,01 x 69,96 cm.
  • But if I add --dpi-x=300 --dpi-y=300 to the command, rsvg-convert --dpi-x=300 --dpi-y=300 --width=1050mm --keep-aspect-ratio svg.svg > reduced.png, the dimensions are 328,14 x 218,55 cm.

Is there any way to set the pixel density while keeping the width fixed?

I mean, there's a big difference between the picture in PNG and SVG when I see them both on Inkscape side by side, I want the PNG (left) to has the resolution of the SVG (right) while keeping the dimensions.