I have bunch of svg images (1.svg 2.svg ...) and i would like to center them and resize canvas to the same value for all of them. Let's say that image 1.svg has w. 600 and h. 800 and 2.svg has w. 1000 and h. 400. I would like to set canvas for both as 1000x800 and center images. As the result the images won't be resized, but they will have extra space on sides -> 1.svg will still be 600x800 but in canvas with size 1000x800 and 2.svg will be 1000x400 but in canvas with size 1000x800. Is it possible to do in command line? Using inkscape, imagemagick etc.?
Thanks in advance!
You need the -extent
option to ImageMagick, like this:
convert 1.svg -gravity center -background yellow -extent 1000x800 result.png
So, let's make some images:
convert -size 600x800! xc:red 1.png
convert 1.png -gravity center -background yellow -extent 1000x800 result.png
Or the other way:
convert -size 1000x400! xc:red 2.png
convert 2.png -gravity center -background blue -extent 1000x800 result.png
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With