将画布大小调整一半 imagemagick

use*_*981 1 image imagemagick

如何将可变尺寸的图像调整为当前尺寸的一半?

即:
30x30 至 15x15
40x40 至 20x20
60x60 至 30x30

重力:左上

Mar*_*ell 7

再次更新

convert input.png -extent 50% -background none output.png
Run Code Online (Sandbox Code Playgroud)

再次更新

也许你的意思是这样的:

convert input.jpg -extent 50% output.jpg
Run Code Online (Sandbox Code Playgroud)

更新答案

也许你的意思是像这样裁剪掉图像的中心:

convert input.jpg -gravity center -crop 50% output.jpg
Run Code Online (Sandbox Code Playgroud)

原答案

像这样:

identify input.jpg    # Check dimensions of input image
input.jpg JPEG 304x304 304x304+0+0 8-bit sRGB 37KB 0.000u 0:00.000

# Convert the image to half its size
convert input.jpg -resize 50% output.jpg

identify output.jpg   # Check dimensions of output image
output.jpg JPEG 152x152 152x152+0+0 8-bit sRGB 20.2KB 0.000u 0:00.000    
Run Code Online (Sandbox Code Playgroud)