0

I have a batch of 14,000 images which are all different formats (.jpg, .png, and .svg), and I'd like to make the height on all of them 550px max while maintaining aspect ratio. I'm stuck on how to batch edit the 11,000 .svg's heights.

I've downloaded homebrew to try and use line code from this: https://github.com/vieron/svg-resizer#svg-resizer but I'm clearly way in above my head with this and can't get the code to work. I can't find it on install, and I don't know how to type in the code on my terminal.

I've also tried Imagemagick but I can't seem to batch edit and it causes an error in the .svg files. I use the command 'Magick convert image.svg -resize 550px newimage.png'

I even tried using svg2png to try and convert images into png files so I can resize them in this app and then convert them back into svg, but I don't know how to do this either.

So then I tried the mac's 'automator' app to make a shortcut to resize images. But it doesn't seem to work with .svg images and I can only change the width.

Now I'm stuck, please could you help me find a solution by telling me what code to type in for these? Or redirect me to a better method.

6
  • 1
    If you convert SVG to PNG you won't be able to convert back - SVG is vector and PNG is raster, once you go raster you lose the vector information. Why do you need to resize the SVG anyway? Scalable Vector Graphics, it's in the name...
    – Luciano
    Jun 9, 2020 at 15:56
  • Welcome on GD.SE, Guest. Your question is similar to this, and it's a bit unclear what you would like to do, remember that most programs can represent SVG files at the desired size, because SVG is a vector format (see here). Exporting SVG to PNG is a one-way process, you'd need to trace it to obtain an SVG again. Jun 9, 2020 at 15:57
  • Thanks for the reply, I'm using a software that layers a .svg over a .jpg, and the .svg image masks over the labels of the .jpg image (covering the labels in diagrams for quizzes). The svg images need to be the same height and aspect ratio as the .jpg to mask the right parts of the image. The question you linked to is helpful, but all my images have different heights and aspect ratios so I don't know how to use find and replace for different values.
    – Guest
    Jun 9, 2020 at 16:17
  • @Guest You can scale SVG images using command-line tools rsvg-convert, which gets in input the desired width and height, or you can use sed (see here and here). For MacOS see this. Jun 9, 2020 at 17:15
  • @Paolo Gibelini I'm typing in 'rsvg-convert -h 550.svg' and it comes out with "Cannot parse integer value “550.svg” for -h". How can I fix that?
    – Guest
    Jun 9, 2020 at 18:36

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.