ImageMagick is the tool for transforming images.
The command line mogrify is excellent for changing the size of an image. mogrify -geometry does that, maintaining the image's aspect ratio (the specified width and height are maximum values) append the geometry with an exclamation point to force a change to aspect ratio.
Rotate an image with -rotate
Reduce the colors in an image: mogrify -colors 2 filename
To also dither the image: mogrify -colors 4 -dither filename
Monochrome image: mogrify -monochrome filename
Annotate image: mogrify -comment 'Hi there' filename
Add borders to image (pixel width and height): mogrify -border 2x4 filename
Decorative border: mogrify -frame 20x20 filename