Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a random .PNG file on my Mac. Actually I have about a hundred of them. What is the easiest way to get the pixel dimensions? (I.e, 100 pixels wide and 50 high, or whatever).

share|improve this question
Doesn't that just show up when you view the file properties? – tjameson Apr 20 '11 at 2:39
I right click, then click "Get info", and don't see it. – William Jockusch Apr 20 '11 at 2:40
up vote 21 down vote accepted

In Terminal, you can use the following:

$ sips -g pixelWidth Pictures/238337225.png 
  pixelWidth: 1140
$ sips -g pixelHeight Pictures/238337225.png 
  pixelHeight: 900

To extract the value only, use e.g.

$ sips -g pixelHeight Pictures/238337225.png | tail -n1 | cut -d" " -f4

To embed that in AppleScript:

set h to do shell script "sips -g pixelHeight /Users/danielbeck/Pictures/238337225.png | tail -n1 | cut -d' ' -f4"
set w to do shell script "sips -g pixelWidth /Users/danielbeck/Pictures/238337225.png | tail -n1 | cut -d' ' -f4"
display alert "Height: " & (h as text) & "
Width: " & (w as text)


enter image description here

Alternatively, you can read the Spotlight metadata:

mdls Pictures/238337225.png | grep kMDItemPixel
kMDItemPixelCount              = 1026000
kMDItemPixelHeight             = 900
kMDItemPixelWidth              = 1140

To get the names and dimensions of all files in a directory:

$ mdls Pictures/* | grep "\(kMDItemDisplayName\|mMDItemPixel\)"
kMDItemDisplayName             = "url.png"
kMDItemPixelCount              = 16384
kMDItemPixelHeight             = 128
kMDItemPixelWidth              = 128

Or alternatively, using find and sips:

find /Users/danielbeck/Pictures -type f -name "*.png" -exec sips -g pixelWidth {} \; -exec sips -g pixelHeight {} \;

More more flexibility, wrap in a shell script:

$ cat 
#!/usr/bin/env bash


if [ ! -f "$filename" ] ; then
    echo "$filename not found!";
    exit 1

h=$( mdls "$filename" | grep kMDItemPixelHeight | tail -n1 | cut -d= -f2 )
w=$( mdls "$filename" | grep kMDItemPixelWidth | tail -n1 | cut -d= -f2 )

osascript -e "tell application \"Finder\" to {activate, display alert \"$filename\\nWidth:$w\\nHeight:$h\"}"

Result after chmod +x dim/sh:

$ ./ Pictures/flying_cars.png

enter image description here

You could easily extend the script to display dimensions for multiple files at once, or e.g. all png files in a certain directory. Output is as Finder dialog, so you can embed it into an Automator service:

Open Automator and select to create a Service that receives image files as input in any application.

Add a Run Shell Script action that receives input as arguments and enter the following:

for f in "$@"
    h=$( mdls "$f" | grep kMDItemPixelHeight | tail -n1 | cut -d= -f2 )
    w=$( mdls "$f" | grep kMDItemPixelWidth | tail -n1 | cut -d= -f2 )
    dlg="$dlg$f\nW:$w H:$h\n"
osascript -e "tell application \"Finder\" to {activate, display alert \"$dlg\"}"
exit 0

Save as Show Image Dimensions. Select a few image files in Finder and select Finder » Services » Show Image Dimensions or Right-click on one of the files and [Services »] Show Image Dimensions

enter image description here

enter image description here

share|improve this answer

Find the file in a Finder window, and either:

  • Highlight the file and press ⌘ Cmd + ⌥ Option + I, or

  • Control-click the file and hold ⌥ Option so you can select "Show Inspector".

This will open an inspector which is similar to the Get Info window, but updates each time you select a file.

Now expand the "More info" section on the inspector. You will be able to see the PNG's dimensions and color depth, among other data. Select a new file to see its dimensions in the inspector.

An inspector window showing the highlighted file in a Finder window

share|improve this answer
The weird thing is that when I open that window, what I see under "more info" is Title, Headline, and Last Opened . . . but no dimensions, color space, color profile, or alpha channel. My OS is 10.6.7 and my Finder is version 10.6.8; could that be the problem? – William Jockusch Apr 20 '11 at 5:24
This feature depends on Spotlight to index the image's location. Are the picture in a non-indexed location? – Stephen Jennings Apr 20 '11 at 6:45

This is an old question, but for current readers, there is now a readily available solution. In Yosemite, you can turn on the "Show Preview Column" in Finder. Finder > View > Show View Options

Here's a screenshot.


share|improve this answer
sadly the question was posted in 2011 and yosemite was released in 2014 – Francisco Tapia Sep 28 '15 at 16:51
@karel i agree with you, i've reverted my vote, and is basically because the OP hasnt a tag for an especific os version. – Francisco Tapia Sep 28 '15 at 17:22
@FranciscoTapia Thank you for responding quickly and I encourage you to continue your reviewing efforts. – karel Sep 28 '15 at 17:24
yeah, it was the number 1 search result when i looked for answer to this problem on Google, so i thought others would benefit from my answer – whalesharkie Sep 28 '15 at 19:56

The easiest way; open the images in Safari.

Select all the images. Then use Ctrl+Click context menu and choose Open With > Safari.

Optionally you can merge all the open Safari menus together into separate tabs using the Safari menu Window > Merge All Windows.

The top of the Safari window displays the image dimensions: enter image description here

share|improve this answer
I find it really bizarre that this is the only option that worked for me. Why do I have to open a browser to view picture dimensions ?!? This is ridiculous. Thanks for the answer nevertheless – Michael May 7 '15 at 22:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.