Search notes:

ImageMagick

Image attributes such as their size can be changed with convert.
Note, Windows comes with a convert.exe. In order to use Image Magick's convert, either the full path to Image Magick's convert needs to be entered or the PATH environment variable needs to have the ImageMagick installation directory before the Windows System32 directory.

Installation

On Windows, ImageMagick can be installed with Chocolatey.
choco install -y imagemagick
choco install -y imagemagick.app
choco install -y imagemagick.tool
choco install -y imagemagick      -packageParameters installDevelopmentHeaders=true
imagemagick seems to install both, imagemagick.app and imagemagick.tool.
In order to install the header files for ImageMagick, -packageParameters installDevelopmentHeaders=true must be added.
In order to legacy utilities (such as convert), -packageParameters legacySupport=true must be added.

Resize an image

The following snippets demonstrate how an image, named in.jpg can be resized. The resized image will be named out.jpg.
Change width to 400 pixels:
magick convert in.jpg -resize 400 out.jpg
Change height to 300 pixels:
magick convert in.jpg -resize x300 out.jpg
At most 400x300, keeping aspect ratio
magick convert in.jpg -resize 400x300 out.jpg
Force specific size
magick convert in.jpg -resize 400x300! out.jpg
convert is a legacy command that did the same as magick convert should be used instead.

Change type (jpg -> png etc)

magick convert in.png -format jpg out.jpg
TODO: Apparently, jasper comes with a program to convert between types as well.

Change quality (loss)

magick convert in.jpg -quality 85 out.jpg

Keep file (don't create another file)

Use mogrify instead of convert to modify the size of an image without creating a new image (in place modification). Thus, the original file will be lost after the operation.
magick mogrify -resize 400x300! file.png 
TODO: Apparently, jasper comes with a program to convert between types as well.

Information (dimensions...) about an image

magick identify image.png
identify can be given a format string (much like printf) where %… are replaced with the values of attributes and properties of an image.
The following example prints width, height, and x and y resolution of an image:
magick identify -format "The image is %w by %h pixels, its x resolution is %x, and its y resolution is %y" image.png

Screenshots

import -window root screenshot.jpg
Without the -window option, import allows to select a window or an aribtrary region interactively.
See also Perl modules Win32::Screenshot and ImageMagick::Screenshot

Apparently, in earlier (legacy) versions of ImageMagick, mogrify could be used in place of magick mogrify and convert in place of magick convert.

TODO

Do these commands come with a graphicsmagick alternative that can be enabled(?) by prepending these commands with gm?

Links

Fred's ImageMagick scripts

Index