批量调整图像大小,并使用 ImageMagick 将图像输出到新文件夹

当前图像文件夹路径:

public_html/images/thumbs

输出图像文件夹路径:

public_html/images/new-thumbs

我有10个视频大拇指每视频在当前文件夹,命名为图像大拇指:

1-1.jpg
1-2.jpg
1-3.jpg
1-4.jpg
1-5.jpg (Resize)
1-6.jpg
1-7.jpg
1-8.jpg
1-9.jpg
1-10.jpg


2-1.jpg
2-2.jpg
2-3.jpg
2-4.jpg
2-5.jpg (Resize)
2-6.jpg
2-7.jpg
2-8.jpg
2-9.jpg
2-10.jpg

我想调整所有第5张图片的大小(*-5.jpg)到新的文件夹:

mogrify
-path
public_html/images/thumbs/*-5.jpg
-resize 16×12
-quality 100
public_html/images/new-thumbs/*-5.jpg
99092 次浏览

"Mogrify" should be called from the directory with the original thumbnails, while the -path parameter is for pointing target directory.

mkdir public_html/images/new-thumbs
cd public_html/images/thumbs
magick mogrify -resize 16x12 -quality 100 -path ../new-thumbs *.jpg

http://www.imagemagick.org/Usage/basics/#mogrify

The last arguments are the list of files, so you can filter by name 1-*.jpg for example.

For those having Shotwell installed on Ubuntu/Debian, following may be more easy to export selected images in a folder to another folder through processing the images as needed.

  • Open Shotwell
  • Select the images you want to export
  • File > Export
  • Adjust the values to your needs
  • Select the folder to export

In ImageMagick 7 versions its built into the magick ...so..

magick mogrify -resize 16x12 -quality 100 -path ../new-thumbs *.jpg

Make sure that the folder you specify in path exists. It will not be created by ImageMagick.

Find more information here https://www.imagemagick.org/script/mogrify.php

Suggested solutions do not work properly on the latest ImageMagick (at least, on macOS). Command, that works overwriting source images is as follows:

magick mogrify -path ./ -resize 50% -quality 80 *.jpg

To avoid overwriting the original images, write to a new folder:

magick mogrify -path path/to/destination/folder/ -resize 50% -quality 80 *.jpg