Question

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.

Était-ce utile?

La solution

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
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top