批量调整图像到使用ImageMagick新的文件夹 [英] Batch resize images into new folder using ImageMagick
问题描述
我有图片超过 4MB
文件夹 - 我们姑且称之为该文件夹 dsc_big /
。我想使用转换-define JPEG:程度= 2MB
将它们转换为根据 2MB
复制 dsc_big / *
到文件夹 dsc_small /
已存在。
I have a folder of images over 4MB
- let's call this folder dsc_big/
. I'd like to use convert -define jpeg:extent=2MB
to convert them to under 2MB
and copy dsc_big/*
to a folder dsc_small/
that already exists.
我试过转换dsc_big / * -define JPEG:程度= 2MB dsc_small /
,但产生的图像名为 -0
, 1
,等等。
I tried convert dsc_big/* -define jpeg:extent=2MB dsc_small/
but that produces images called -0
, -1
, and so on.
我该怎么办?
推荐答案
转换
被设计用来处理一个单一的输入文件,据我所知,虽然要承认我不明白,你得到的输出。 mogrify 是在下面的风格更适合批量处理:
convert
is designed to handle a single input file as far as I can tell, although I have to admit I don't understand the output you're getting. mogrify is better suited for batch processing in the following style:
mogrify -path ../dsc_small -define jpeg:extent=2MB dsc_big/*
但老实说,我认为这是危险的普遍使用,(它会覆盖原来的图像,如果你忘了 -path
),所以我总是用频转换再加
用for循环这样的:
But honestly I consider it dangerous for general usage (it'll overwrite the original images if you forget that -path
) so I always use convert
coupled with a for loop for this:
for file in dsc_big/*; do convert $file -define jpeg:extent=2MB dsc_small/`basename $file`; done
的基本名
通话,如果你在当前目录中处理文件是没有必要的。
The basename
call isn't necessary if you're processing files in the current directory.
这篇关于批量调整图像到使用ImageMagick新的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!