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).
In Terminal, you can use the following:
To extract the value only, use e.g.
To embed that in AppleScript:
Alternatively, you can read the Spotlight metadata:
To get the names and dimensions of all files in a directory:
Or alternatively, using
More more flexibility, wrap in a shell script:
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:
Save as Show Image Dimensions. Select a few image files in Finder and select Finder » Services » Show Image Dimensions or
Find the file in a Finder window, and either:
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.
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.
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: