在imagemagick中将两个文件夹中的图像合二为一。
你好,
我有一个包含此列表图像的文件夹:
如何使用imagemagick水平合并所有这些:
的Vesa
答案 0 :(得分:0)
我通常不会写BATCH文件,但这对我有用 - 可能有更好的方法...
@ECHO OFF
REM Combine images side-side pairwise from the current directory using ImageMagick
REM Images are assumed to be named file1.jpg, file2.jpg, file3.jpg
REM Images are resized to a common height, as specified on next line
SET HEIGHT=500
SETLOCAL ENABLEDELAYEDEXPANSION
FOR /L %%A in (1,2,1000) DO (
SET /A "B=%%A+1"
SET _f1=file%%A.jpg
SET _f2=file!B!.jpg
IF NOT EXIST "!_f1!" GOTO BRK
IF NOT EXIST "!_f2!" GOTO BRK
SET _result=joined%%A_!B!.jpg
ECHO Joining !_f1! and !_f2! into !_result!
convert "!_f1!" "!_f2!" -resize x%HEIGHT% +append "!_result!"
)
:BRK
我不知道你是如何在Windows中进行while
循环的,所以我使用的是for
循环。我猜你的文件不超过1,000个。如果这样做,请在第三行增加1,000。您可以在脚本顶部更改调整图像大小的公共高度。
一般情况下,如果您要列出两个名称不符合fileXYZ.jpg
命名标准的图片,请说明它们是imageA.jpg
和imageB.jpg
,旁边相互之间并将其调整为500像素高并保存为result.jpg
您将要执行的操作
convert imageA.jpg imageB.jpg -resize x500 result.jpg