The imagemagick site has a demo on this page: http://www.imagemagick.org/Usage/resize/#resize
I want to perform the action in this example:
convert logo: -resize 80x80\> \
-size 80x80 xc:blue +swap -gravity center -composite \
space_resize.jpg
But for a large number of files. I think the right tool 开发者_JAVA百科is mogrify, but it does not know the +swap or xc:blue flags.
Advice?
I was able to accomplish the above by using the following:
mogrify -resize 300x300 *.jpg
mogrify -extent 300x300 -gravity Center -fill white *.jpg
This will make the largest dimension of the images to 300 pixels. It will then fill the canvas on the shorter dimension to 300 pixels and fill in the empty space with white.
For me your solution just clips 300x300 portion from my big image.
Next command works correctly, adding white space around image:
mogrify -extent 640x640 -gravity Center -fill white *.jpg[640x640]
to extend @akoumjian's resolution I just suggest to use
-transparent white
parameter to get transparent all what was white on the image. It's great for making transparent PNGs
精彩评论