How do I batch resize all images to sqares with Image Magick?

主宰稳场 提交于 2020-01-16 13:10:11

问题


OK. I have a horizontal image, let's say 2000 x 300. I want to overwrite that image and create a new one that is 2000 x 2000 with the old image center in the middle and vertically, with white space around it. I also want to do this in batch with many different images of different sizes. Thanks in advance.


回答1:


Use -resize to resize the image to 2000x2000, -background to set the background to white, -gravity to center the original image on the canvas, and -extent to resize the canvas itself (to cause the image to sit in the centre if it wasn't square originally).

convert [imagename] -resize 2000x2000 -background white \
                    -gravity center -extent 2000x2000 [imagename]


来源:https://stackoverflow.com/questions/8793777/how-do-i-batch-resize-all-images-to-sqares-with-image-magick

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