调整大小以适合盒子,并在“空"菜单上将背景设置为黑色.部分 [英] Resize to fit in a box and set background to black on "empty" part
问题描述
我正在尝试获得以下结果:固定的框大小(133x100),应调整图像的大小但不能拉伸以适合该框内的空白应该用黑色填充.
I'm trying to obtain this result: fixed box size (133x100), the image should be resized but not stretched to fit inside that box, the empty space should be filled with black.
我实际上正在尝试使用此命令:
I'm actually trying with this command:
convert -background black -gravity center -extent 133x100 from.jpg to.jpg
但是,我没有将图像放置在请求的框内,而是获得了图像的一部分. 如何获得要求的结果?我正在研究文档,但是有很多选择,但我仍然没有找到(我认为)我需要的一个选择.
However instead of fitting the image inside the requested box, I obtain a crop of the image. How to obtain the requested result? I'm digging into documentation but there are a lot of options and I still didn't find (I think) the one that I require.
推荐答案
Looks like I've found the solution by myself with this link: http://www.imagemagick.org/Usage/thumbnails/#fit_summery
这段代码解决了我的问题:
And this code solved my issue:
convert from.jpg -thumbnail 133x100 -background black -gravity center -extent 133x100 to.jpg
这篇关于调整大小以适合盒子,并在“空"菜单上将背景设置为黑色.部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!