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.

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

Example output:

1550x1037

Example output if it’s not an image file

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