问题描述
我需要将文件夹中的所有图像从svg转换为png.可以说图像称为test1.svg,test2.svg,...,testn.svg.使用以下脚本:
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
正确地完成了工作,这些图像分别称为test1.svg.png,test2.svg.png,...,testn.svg.png.我的问题是:
does the job correctly, and the images are called test1.svg.png, test2.svg.png, ... , testn.svg.png. My questions are:
1)是否可以将输出图像命名为test1.png,test2.png,...,testn.png,从而从名称中删除"svg"部分?
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)是否可以将它们直接发送到其他目录?
2) Is it possible to send them directly into some other directory?
谢谢!
推荐答案
是.您可以创建另一个目录,并将其发送到该目录,如下所示:
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
如果要处理大量图像,并且您使用的是macOS或Linux,我建议 GNU Parallel 以更快地完成工作:
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
这篇关于将一堆图像从svg转换为png的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!