$ mogrify -geometry x31 path/to/image.gif
mogrify is part of
ImageMagick, an image manipulation software suite
mogrify manipulates the specified images. If you prefer to keep the original image untouched and write the manipulated image to a different file, simply replace
convert, the syntax is the same, but the last command line argument will be the target image to write to.
-geometry flag is to resize the image, it requires a dimension parameter in the format
- The dimension in this example has no width, which means the image will be resized to height=31 pixels, and the width will be proportional.
ImageMagick is not a standard package, though it is open source and available in many systems.