Executing bash convert commands asynchronously

谁说我不能喝 提交于 2019-12-07 02:06:30

If you have many images, running hundreds/thousands of convert processes in parallel is not going to work very well and you would be better off with GNU Parallel which will keep all your CPU cores busy without overloading the system - so if you have 8 cores, it will do 8 images at a time (though you can change that).

So, if you wanted to resize all the JPG images in your directory down to half their original size and rename them resized-XYZ.jpg:

parallel convert {} -resize 50% resized-{} ::: *.jpg

If you want to do all the JPG files and the PNG files and see a progress meter as they run:

parallel --progress convert {} -resize 50% resized-{} ::: *.jpg *.png

If you want to do specifically 8 at a time, use:

parallel -j8 ....

If you want to see what the command is going to do, without actually doing anything:

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