Basic resizing with different end
# Resize to fit within 800x600, preserving aspect ratio
magick input.png -resize 800x600 output.png
# 1000x1000 -> 600x600, 1600x1000 -> 800x500
# Resize by percentage, rounds to closest integer pixel which can be off compared to exact pixels
magick input.png -resize 50% output.png
# 1000x800 -> 500x400, 800x593 -> 400x297 (half a pixel too high, could distort)
# Resize to fit 800 height, width will scale to match - move the x to swap
magick input.png -resize x800 output.png
# 200x400 -> 400x800, 1600x1600 -> 800x800
# Force exact dimensions, breaking aspect ratio scaling. Escape like this `\!`
magick input.png -resize 1100x800\! output.png
# 1600x900 -> 1100x800
# Only shrink larger images, never enlarge smaller. Escape like this `\>`
magick input.png -resize x800\> output.png
# # 200x400 -> 200x400, 1600x1600 -> 800x800
# Resize based on smallest fitting dimension, Image will fill and overflow. Useful together with -crop/-extent
magick input.png -resize 800x800^ output.png
# 200x400 -> 800x1600, 1000x2000 -> 800x1600
# Resize to fit within size but keep aspect ratio and fill/pad with black
magick input.png -background black -resize 400x400 -gravity center -extent 400x400 output.png
# 800x400 -> 400x400
# original image will first scale to 400x200 then pad with black top+bottom calculated from center
# The above example to keep aspect ratio but remove overflow, fill and crop
magick input.png -resize 1920x1080^ -gravity center -extent 1920x1080 output.png
# 1920x1200 -> 1920x1080, 1600x1400 -> 1920x1080
Batch resize images
Some examples, could use with any of the above.
# Resize all jpgs to 60% of their original size
for i in *.jpg; do magick $i -resize 60% "60_$i"; done
# Resize a directory full of wallpapers to overflow and crop, `-backgroun none` to preserve transparency
for i in *.png; do magick "$i" -background none -resize 1920x1080^ -gravity center -extent 1920x1080 "${i%.png}_1920x1080.png"; done