如何使用 imagemagick 调整图像大小并将其填充到给定大小?

puz*_*ent 11 imagemagick image-editing

说我有这不同图像的目录3024×40324032×3024像素,并且我希望他们都调整到1920×1080

我想要那个确切的输出尺寸,但我不希望图像扭曲以适应尺寸,所以我希望边缘根据需要填充黑色以保留原始图像的纵横比。根据需要填充图像的 ImageMagick 命令行是什么?

puz*_*ent 10

对于每个图像,此命令将生成一个1920x1080图像版本,居中,边缘在需要的地方填充为黑色:

convert [input file] -resize 1920x1080 -background black -gravity center -extent 1920x1080 [output file]
Run Code Online (Sandbox Code Playgroud)

来源:标志的ImageMagick 文档-extent