Convert a bunch of images from svg to png

我只是一个虾纸丫 提交于 2019-12-11 00:26:38

问题


I need to convert from svg to png all the images in a folder. Lets say that images are called test1.svg, test2.svg, ... , testn.svg. Using the following script:

for i in *.svg
do
    convert "$i" PNG24:"$i".png
done

does the job correctly, and the images are called test1.svg.png, test2.svg.png, ... , testn.svg.png. My questions are:

1) Is it possible to make the output images be called test1.png, test2.png, ... , testn.png, essentially removing the 'svg' part from the name?

2) Is it possible to send them directly into some other directory?

Thanks!


回答1:


Yes. You can make another directory and send them there like this:

mkdir other
for i in *.jpg; do
   convert "$i" PNG24:other/"${i%jpg}png"
done

If you have lots of images to do, and you are on macOS or Linux, I would recommend GNU Parallel to get the job done faster:

mkdir other
parallel convert {} PNG24:other/{.}.png ::: *jpg


来源:https://stackoverflow.com/questions/45139748/convert-a-bunch-of-images-from-svg-to-png

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!