image magick

Only shrink larger images

convert test.png -resize 800x600\> shrink_test.png

Shrink and convert to webp

convert test.png -resize 800x600\> test.webp

Trim borders and shrink if larger

convert phb5.png -trim -resize 140x183\> phb5.png

See also