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
6.76388888888888888888

Height in inches

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

Comments

Click here to write/view comments