Get image width and ppi using imagemagick identify on command line

Imagemagick identify is pretty handy utility to get information about an image. You need to have imagemagick installed on your Mac or Linux for the purpose of this tutorial. Here are some scenarios to get image information:

Print image size (pixels) and PPI

Image size (pixels)

$ identify -format "Pixel Size: %w x %h\n"  img1.png
Pixel Size: 487 x 259

Image PPI (pixels per inch)

$ identify -format "PPI: %x x %y\n"  img1.png
PPI:72 x 72

Note: to find actual image size, you can divide pixel width by width PPI.

Print image width and height in inches

Width in inches

$ identify -format "%w/%x\n" img1.png | bc -l

Height in inches

$ identify -format "%h/%y\n" img1.png | bc -l
Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit


Click here to write/view comments