Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resize canvas by half imagemagick

How to resize a image of variable sizes to half of its current size?

That is :
30x30 to 15x15
40x40 to 20x20
60x60 to 30x30

Gravity:Top-Left

like image 804
user3622981 Avatar asked Jan 29 '26 21:01

user3622981


1 Answers

Updated Yet Again

convert input.png -extent 50% -background none output.png

Updated Again

Maybe you mean this:

convert input.jpg -extent 50% output.jpg

Updated Answer

Maybe you mean cropping out the centre of the image like this:

convert input.jpg -gravity center -crop 50% output.jpg

Original Answer

Like this:

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    
like image 76
Mark Setchell Avatar answered Feb 01 '26 19:02

Mark Setchell