How to get image size in pixel (WxH) on the command line in Linux

You can use the following command to get the size of an image file in pixels. For this example, plot.png will be the filename of the image file you want to check.

image_size.sh
identify -format "%wx%h\n" plot.png

Example output:

image_size_output.txt
1550x1037

Example output if it’s not an image file

image_size_error.txt
identify-im6.q16: no decode delegate for this image format `PY' @ error/constitute.c/ReadImage/580.

Check out similar posts by category: Linux