14

I am looking for a nice and quick way to display the dimension of an image from OS X 10.9. Presently, I have to open the image in photoshop and then enter a menu to know the dimensions. The process is too slow when I have to browse through dozens of pictures and get those with dimensions big enough.

2
  • It's not clear (from the answers given, at least), whether you mean "resolution" or "size". The Resolution of an image is how many pixels per inch it contains, e.g 72dpi. The Dimensions, or size, is how many pixels it contains in total.
    – benwiggy
    May 15, 2019 at 8:08
  • When you say "display the dimensions... from OS", do you mean GUI option/plugin, command-line, or either? The title is too vague. The existing answers mostly assumed you meant 'GUI option/plugin'.
    – smci
    Jul 16, 2022 at 21:27

9 Answers 9

9

Get Info

You can get the resolution from Get Info menu. Select the image and press ⌘ CMD+i, or right click on that image and choose Get Info menu item.

enter image description here Image from cultofmac.com

QuickLook plugin

If you weren't on 10.9 - this lightweight QuickLook plugin called qlImageSize which can be found on GitHub lets You check the image size on the quicklook window title. I don't have any that work on 10.9, but perhaps this will help you if you wish to search for a similar one or report 10.9 compatibility to that project for improvement.

enter image description here

6
  • Unfortunately, this plugin does not work for 10.9
    – Colas
    Feb 11, 2015 at 10:56
  • Ups, just read the bottom of the README. You're right. Feb 11, 2015 at 10:59
  • I couldn't find it again so anyway thanks! I am sure it will help other users.
    – Colas
    Feb 11, 2015 at 11:00
  • 1
    This option does not appear in macos Catalina.
    – jalone
    May 19, 2020 at 10:26
  • 1
    this works on big slur
    – austingae
    Apr 30, 2022 at 4:44
9

The simplest way from the command line is to use the built-in file command:

file ping-pong.png

Outputs:

ping-pong.png: PNG image data, 380 x 343, 8-bit/color RGBA, non-interlaced

More metadata will be displayed if available.

This will also work on Linux systems. See: https://superuser.com/questions/275502/how-to-get-information-about-an-image-picture-from-the-linux-command-line

1
  • This is nice in that it doesn't require to install any software, but it'll return a variable number of fields (at least in my case with a mix of JPEG, PNG, GIF, WEBP), making the results a pain to parse. magick identify "$1" | cut -d' ' -f1,3 from @SztupY's answer is better in this respect. Apr 5, 2022 at 8:14
7

From the command line, if you have Imagemagick 7.x installed (for example through homebrew or the installer), then you can use the following command to quickly display the resolution and similar information of multiple images in a directory (if you are still on the older Imagemagick 6.x, then the command is just identify instead of magick identify):

$ ls
a.jpg
b.png
c.png
$ magick identify *
a.jpg JPEG 550x309 550x309+0+0 8-bit sRGB 29.4KB 0.000u 0:00.000
b.png[1] PNG 1912x827 1912x827+0+0 8-bit sRGB 2.17MB 0.000u 0:00.009
c.png[2] PNG 311x262 311x262+0+0 8-bit sRGB 185KB 0.000u 0:00.000

Or if you only need the resolution:

$ magick identify * | cut -d' ' -f1,3
a.jpg 550x309
b.png[1] 1912x827
c.png[2] 311x262

Specifying -verbose will give you even more quick information which you can grep in case it's needed:

$ magick identify -verbose c.png
Image: c.png
  Format: PNG (Portable Network Graphics)
  Mime type: image/png
  Class: DirectClass
  Geometry: 311x262+0+0
  Units: Undefined
  Type: TrueColor
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
  Channel statistics:
    Red:
      min: 0 (0)
      max: 255 (1)
      mean: 154.515 (0.60594)
      standard deviation: 66.9006 (0.262355)
      kurtosis: -0.83131
      skewness: -0.468887
    Green:
      min: 0 (0)
      max: 255 (1)
      mean: 148.544 (0.582527)
      standard deviation: 77.5386 (0.304073)
      kurtosis: -1.18136
      skewness: -0.438364
    Blue:
      min: 27 (0.105882)
      max: 255 (1)
      mean: 176.548 (0.692343)
      standard deviation: 62.2995 (0.244312)
      kurtosis: -0.971188
      skewness: -0.584194
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 159.869 (0.626937)
      standard deviation: 69.2078 (0.271403)
      kurtosis: -0.754397
      skewness: -0.568073
  Rendering intent: Perceptual
  Gamma: 0.454545
  Chromaticity:
    red primary: (0.64,0.33)
    green primary: (0.3,0.6)
    blue primary: (0.15,0.06)
    white point: (0.3127,0.329)
  Background color: white
  Border color: srgb(223,223,223)
  Matte color: grey74
  Transparent color: black
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 311x262+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: Zip
  Orientation: Undefined
  Properties:
    date:create: 2015-02-11T15:20:41+00:00
    date:modify: 2015-01-28T10:04:15+00:00
    png:iCCP: chunk was found
    png:IHDR.bit-depth-orig: 8
    png:IHDR.bit_depth: 8
    png:IHDR.color-type-orig: 2
    png:IHDR.color_type: 2 (Truecolor)
    png:IHDR.interlace_method: 0 (Not interlaced)
    png:IHDR.width,height: 311, 262
    signature: 35b3a0e9c50c785bece1ceff5a202823922cc78c2740cf9e0ff30d6143c89fdf
  Profiles:
    Profile-icc: 3276 bytes
  Artifacts:
    filename: c.png
    verbose: true
  Tainted: False
  Filesize: 185KB
  Number pixels: 81.5K
  Pixels per second: 2.716MB
  User time: 0.000u
  Elapsed time: 0:01.029
  Version: ImageMagick 7.0.10-34 Q16 x86_64 2020-10-09 https://imagemagick.org
3
  • Why, its built in?
    – JW_
    Feb 16, 2015 at 21:06
  • @JW_: it wasn't a criteria in the original post to be a built in
    – SztupY
    Feb 16, 2015 at 22:55
  • Damn! That's a bunch of great info about images.
    – andreas
    Dec 11, 2020 at 12:26
6

The fastest way is to have the resolution details visible all time ;)

Check out the step below:

Select "Show View Options" by right clicking on the desktop

Check the box "Show item info"

Now its visible under the filename

For column view

*COLUMN VIEW

4
  • Does it work in the list mode?
    – Colas
    Feb 17, 2015 at 10:25
  • @Colas no, but if you just select one file in a list view you get all the info in the column to the right..
    – JW_
    Feb 18, 2015 at 0:27
  • Post is updated.
    – JW_
    Feb 18, 2015 at 0:33
  • @Colas I mistakenly compared column view with list view. Sorry about that. If you want the resolution in list view you may need to hack.
    – JW_
    Feb 18, 2015 at 11:00
2

Not the smoothest, but the following workflow might get you out of trouble:

enter image description here

on run {input, parameters}
    set filename to POSIX path of input
    set h to do shell script "sips -g pixelHeight '" & filename & "' | tail -n1 | cut -d' ' -f4"
    set w to do shell script "sips -g pixelWidth '" & filename & "' | tail -n1 | cut -d' ' -f4"
    display alert (h as text) & " x " & (w as text)
    return input
end run

You can also add a keyboard shortcut if you like:

enter image description here

… but the biggest problem is thinking of a good shortcut that isn’t already being used by something else.

1

This is a trivial task. I have written a c++ program which can display on terminal. I could post if you are interested. It would also be trivial to write a Service to display the result.

//
//  Display  Comment, size of JPEG image
//

#include <iostream>
#include "../jpeg.h"

int main (int argc, const char * argv[])
{
    Cjpeg Jpeg1;

    switch(Jpeg1.OpenJpeg(argv[1]))
    {
        case INVALID_JPEG:
            std::cerr << "Invalid JPEG" << std::endl;
            return INVALID_JPEG;
        case NOTFOUND_JPEG:
            std::cerr << "File Not Found" << std::endl;
            return NOTFOUND_JPEG;
        case NOT_JPEG:
            std::cerr << "Not JPEG" << std::endl;
            return NOT_JPEG;
        default:
            std::cout << Jpeg1.Comments <<  " " <<  Jpeg1.Width <<  " * "  <<  Jpeg1.Height << std::endl;
    }
    return 0;
}

// jpeg.cpp: implementation of the Cjpeg class.
// ANSI version
//////////////////////////////////////////////////////////////////////

#include "jpeg.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

Cjpeg::Cjpeg()
{
    Height = Width = 0;
    Comments[0] = '\0';
}

Cjpeg::~Cjpeg()
{

}

//--------------------------------------------------------------------------
// JPEG markers consist of one or more 0xFF bytes, followed by a marker
// code byte (which is not an FF).
//--------------------------------------------------------------------------

#define M_SOF0  0xC0            // Start Of Frame N
#define M_SOF1  0xC1            // N indicates which compression process
#define M_SOF2  0xC2            // Only SOF0-SOF2 are now in common use
#define M_SOF3  0xC3
#define M_SOF5  0xC5            // NB: codes C4 and CC are NOT SOF markers
#define M_SOF6  0xC6
#define M_SOF7  0xC7
#define M_SOF9  0xC9
#define M_SOF10 0xCA
#define M_SOF11 0xCB
#define M_SOF13 0xCD
#define M_SOF14 0xCE
#define M_SOF15 0xCF
#define M_SOI   0xD8            // Start Of Image (beginning of datastream)
#define M_EOI   0xD9            // End Of Image (end of datastream)
#define M_SOS   0xDA            // Start Of Scan (begins compressed data)
#define M_JFIF  0xE0            // Jfif marker
#define M_APP1  0xE1            // Exif marker
#define M_COM   0xFE            // COMment
#define M_DQT   0xDB
#define M_DHT   0xC4
#define M_DRI   0xDD

// Process a SOFn marker
void Cjpeg::process_SOF (unsigned length)
{
    int data_precision, num_components;
    unsigned char Data[128];
    unsigned long   cb; // count of bytes read

    cb = fread(&Data, 1, length, fp);   // read JPEG

    data_precision = Data[0];
    Height = Get16(Data+1);
    Width = Get16(Data+3);
    num_components = Data[5];
}

// Process a COM marker.
void Cjpeg::process_COM (unsigned length)
{
    unsigned nch;
    unsigned long   cb; // count of bytes read

    nch = 0;

    nch = (length > MAX_COMMENT) ? MAX_COMMENT : length;    // Truncate if it won't fit in our structure.
    cb = fread(&Comments, 1, nch, fp);  // read JPEG

    Comments[nch] = '\0'; // Null terminate
    if(cb<length)
    {
        fseek(fp, length - cb, SEEK_CUR);   // point to next JPEG marker
    }
}


void Cjpeg::process_APP1(unsigned int length)
{
    fseek(fp, length, SEEK_CUR);    // point to next JPEG marker
}


int Cjpeg::OpenJpeg(const char *JpegFile)
{
    int count;
    unsigned long   cb; // count of bytes read

    fp = fopen(JpegFile, "rb");
    if(fp == NULL)
    {
        return NOTFOUND_JPEG;
    }
    cb = fread(&JpegMarker, 2, 1, fp);  // read JPEG
    if(JpegMarker[0] != 0xFF || JpegMarker[1] != M_SOI)
    {
        fclose(fp);
        return NOT_JPEG;    // Not JPEG File
    }
    while(cb != 0) // Stop if EOF reached
    {
        cb = fread(&JpegMarker, 2, 1, fp);  // read JPEG marker
        if(JpegMarker[0] != 0xFF)
        {
            fclose(fp);
            return INVALID_JPEG;    // Invalid File
        }
        switch(JpegMarker[1])
        {
            case M_SOS: // stop before hitting compressed data
            case M_EOI: // in case it's a table only JPEG stream
                fclose(fp);
                return 0;   // Normal exit
        }
        cb = fread(&JpegSecCount, 2, 1, fp);    // read length of field
        count = Get16(JpegSecCount);
        count -= 2; // value includes length bytes
        switch(JpegMarker[1])
        {
            case M_COM: // Comment section
                process_COM (count);
                break;

            case M_SOF0:
            case M_SOF1:
            case M_SOF2:
                process_SOF (count);
                break;

            case M_APP1:
                process_APP1 (count);
                break;

            case M_JFIF:

            default:
                // Skip any other sections.
                fseek(fp, count, SEEK_CUR); // point to next JPEG marker
                break;
        }
    }
    fclose(fp);
    return INVALID_JPEG;    // Possible Invalid File
}
2
  • 4
    Congrats on taking a "trivial task" and providing an overly complex solution.
    – Git.Coach
    Nov 29, 2017 at 4:37
  • It's just complex if you can't code. ;) Guess what all the other solutions have in the background...
    – andreas
    Dec 11, 2020 at 12:23
1

There are two simple methods for accomplishing this via the command line:

  • sips - macOS built in tool for image identification and manipulation
  • GraphicsMagick gm identify - FOSS utility similar to ImageMagick but smaller and much more efficient.

Sips

The command to get the image dimensions is as follows:

sips -g pixelWidth -g pixelHeight images_file(s)

What is really convenient here, besides being a native tool included with macOS, is that you can specify which dimension you want (i.e. just the height). It will also accept multiple files at once.

sips -g pixelWidth Logo.bmp Logo.png

Users/allan/Demo/Logo.bmp
pixelWidth: 225
/Users/allan/Demo/Logo.png
pixelWidth: 1141

GraphicsMagick

GraphicsMagick is a cross platform (macOS, FreeBSD, Linux, Windows, etc.) image processing utility designed to be a smaller and more efficient alternative to ImageMagick (referenced in another answer). It’s available via MacPorts and Homebrew.

gm identify foo.bar

Example:

gm identify Logo.bmp
Logo.bmp BMP 225x200+0+0 DirectClass 8-bit 175.9Ki 0.000u 0m:0.000003s

To customize the output, you can use the format flag:

gm identify -format "%wx%h" Logo.bmp
225x200

gm identify -format “My image width is:  %w” Logo.bmp
My image width is:  225
0

If you have Photoshop, you probably also have Bridge. If you have Bridge, you can point it at a folder of images (with the ability to have it display the images in sub-folders of that folder) and then sort the images by a number of ways including by the dimensions of the image in pixels. Clicking on an individual image will show more information including the pixel dimensions. You can also choose the "View -> As Details command" and the list of images will include information that includes the pixel dimensions.

0

In macos 13 Ventura I was able to see dimensions (Image size) after opening file in Preview, then clicking (i) button enter image description here

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .