Batch resize images and output images to new folder with ImageMagick

☆樱花仙子☆ 提交于 2020-01-11 15:51:11

问题


Current image folder path:

public_html/images/thumbs

Output image folder path:

public_html/images/new-thumbs

I have 10 video thumbs per video in current folder, named of image thumbs:

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

I want to resize all 5th images(*-5.jpg) to the new folder. I've tried below command but no luck:

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

回答1:


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

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 pp*.jpg for example.




回答2:


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




回答3:


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



回答4:


Suggested solutions do not work properly on the latest ImageMagick (at least, on macOS). Command, that works (Will rewrite source images!!!):

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


来源:https://stackoverflow.com/questions/14304480/batch-resize-images-and-output-images-to-new-folder-with-imagemagick

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!