MoonPoint Support Logo

 

Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals



Advanced Search
October
Sun Mon Tue Wed Thu Fri Sat
           
4
         
2011
Months
Oct


Tue, Oct 04, 2011 5:12 pm

Determining Image Info Under Mac OS X

If you need to determine information about an image file from the command line on a Mac OS X system, you can use the file command.

If you wanted information about all of the .jpg and .png files in a directory, you could use the command file *.png *.jpg

$ file *.png *.jpg
upgrade-windows-grayed.png:         PNG image, 256 x 256, 8-bit/color RGBA, non-interlaced
Vista_Install_Type_Product_Key.jpg: JPEG image data, JFIF standard 1.01

For some image files, the file command will show the image dimensions. The command will reveal the actual image type, even if a file has been given the wrong extension as shown below.

$ cp Vista_Install_Type_Product_Key.jpg test.png
$ file test.png
test.png: JPEG image data, JFIF standard 1.01

Another useful utility for determining the dimensions of an image file is sips. You can use the -g pixelHeight and -g pixelWidth options to obtain the dimensions of an image.

$ sips -g pixelHeight -g pixelWidth example.jpg 
/Users/jsmith/Documents/example.jpg
  pixelHeight: 600
  pixelWidth: 800

References:

  1. Get the dimensions of most images from the command line UNIX
    Date: December 1, 2003
    Mac OS X Hints

[/os/os-x] permanent link

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo