Batch convert 5000 vectors to PNG with transparency

I have 5000 vector images (mostly eps / svg) that i need to convert to PNG with transparent backgrounds. PNG images need to be maximum 4000x4000px

Any idea what would be the best way to do this ? Most batch image converters won’t support transparency and resizing.

The first part of the task (vector to PNG) could be done using illustrator or photoshop actions, but i haven’t found a way to set max size at 4000×4000 while keeping aspect ratio and maximum resolution matching the requirements

One option could be to split the task and run the PNG through something else to resize them to maximum 4000x4000px… Maybe Inkscape ? I saw some people were able to write python scripts to do similar tasks

the problem is that it’s hard to set the 4000x4000px limit

Answer

That would be a job for the command line tool Image Magick mogrify. The following command:

mogrify -resize '4000x4000' -format png *.svg

Will convert all SVG files in the current folder to PNG keeping the aspect ratio but with the largest side exactly 4000 pixels.

In case we had defined a non-transparent white (or any other color) background in the source SVG we can add transparency with:

mogrify -resize '4000x4000' -transparent white -format png *.svg

Note on Windows command line:
We need to prefix the commands with magick and should not use ticks ' but nothing, or quote marks " instead.

An example Windows command may look like this:

magick mogrify -resize "4000x4000" -transparent white -format png *.svg

Converting EPS files need a density value (in DPI) in addition:

magick mogrify -resize "4000x4000" -density 300 -transparent white -format png *.eps

Attribution
Source : Link , Question Author : Community , Answer Author : Community

Leave a Comment