문제

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top