For this guide we will use below square image in.png (size 300x300) as input image

Imagemagick Resize Images

1. Resize image (keep aspect ratio)

magick in.png -resize 100x100 out-a1.png

Above command will resize the image to fit within those dimensions.

Imagemagick How to Resize image (keep aspect ratio)

You can use ^ carate symbol with dimensions to tell ImageMagick to resize the image to fill the dimensions.

magick in.png -resize 100x150^ out-a2.png

Below command resizes input.jpg to 300 pixels wide and sets the JPEG quality to 75.

magick input.jpg -resize 300 -quality 75 output.jpg

Imagemagick How to Resize image (keep aspect ratio)

2. Forced Resize image (ignore aspect ratio)

magick in.png -resize 300x100! out-b1.png

The ! symbol forces resize of image into any size ignoring aspect ratio. this, as it will stretch the image.

Imagemagick Forced Resize image (ignore aspect ratio)

3. Crop an Image without resizing

By default the -gravity is set to northwest (upper left corner).

magick in.png -crop 150x150+0+0 out-c1.png

Imagemagick Forced Resize image (ignore aspect ratio)

We can change -gravity to southeast (lower right corner) or center

magick in.png -gravity southeast -crop 150x150+0+0 out-c2.png
magick in.png -gravity center -crop 150x150+0+0 out-c3.png

Imagemagick Crop image southeast (lower right corner)

Imagemagick Crop image center