Crop and scale SVG to PNG using ImageMagick without pixelation

I have an SVG with many polygons:

https://github.com/barrycarter/bcapps/blob/master/sample-data/current-temps.svg

It looks something like this:

enter image description here

Trimming this and converting to PNG works fine:

convert -crop 100x100+200+150 current-temps.svg /tmp/exhb2.png

enter image description here

Framing and scaling, however, fail:

convert -crop 100x100+200+150 -scale 1000x750 current-temps.svg /tmp/exhb3.png

enter image description here

How do I get ImageMagick to "zoom" SVG before cropping?

(I understand that ImageMagick can read, not write, the SVG format, but should it still do what I want?)

EDIT / SOLVED:

Thank robermorales

inkscape -z -e out4.png -w 1000 -h 1000 -a 200:200:400:400 current-temps.svg 

(for example) worked like a charm.

I also realized that copying SVG, setting the conversion line:

<g transform="scale(3,3) rotate(-90) translate(-90,180)"> 

and then converting to PNG is another solution.

+5
source share
3 answers

.

inkscape cli .

, afk

+6

SVG PNG. viewBox , SVG PNG . https://www.sarasoueidan.com/blog/svg-coordinate-systems/ , viewBox, .

+1

ImageMagick , , , . . http://www.imagemagick.org/Usage/basics/#why . , -scale . -scale -resize. , , . :

convert current-temps.svg -crop 100x100+200+150 -resize 1000x750 exhb3.png
0
source

All Articles