Color Modes

Command-line Tools: Identify

Example UsageOption Summary

The magick identify program describes the format and characteristics of one or more image files. It also reports if an image is incomplete or corrupt. The information returned includes the image number, the file name, the width and height of the image, whether the image is colormapped or not, the number of colors in the image, the number of bytes in the image, the format of the image (JPEG, PNM, etc.), and finally the number of seconds it took to read and process the image. Many more attributes are available with the verbose option. See Command Line Processing for advice on how to structure your magick identify command or see below for example usages of the command.

Example Usage

We list a few examples of the magick identify command here to illustrate its usefulness and ease of use. To get started, lets identify an image in the JPEG format:

$ magick identify rose.jpg
rose.jpg JPEG 70x46 70x46+0+0 8-bit sRGB 2.36KB 0.000u 0:00.000 

By default, magick identify provides the following output:

    Filename[frame #] image-format widthxheight page-widthxpage-height+x-offset+y-offset colorspace user-time elapsed-time

Next, we look at the same image in greater detail:

$ magick identify -verbose rose.jpg
Image: rose.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Mime type: image/jpeg
  Class: DirectClass
  Geometry: 70x46+0+0
  Units: Undefined
  Type: TrueColor
  Endianness: Undefined
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    Red: 8-bit
    Green: 8-bit
    Blue: 8-bit
  Channel statistics:
    Pixels: 3220
    Red:
      min: 31 (0.121569)
      max: 255 (1)
      mean: 145.557 (0.570814)
      standard deviation: 69.1933 (0.271346)
      kurtosis: -1.38945
      skewness: 0.138955
      entropy: 0.970683
    Green:
      min: 27 (0.105882)
      max: 255 (1)
      mean: 89.246 (0.349984)
      standard deviation: 52.4608 (0.205729)
      kurtosis: 2.60139
      skewness: 1.80708
      entropy: 0.869711
    Blue:
      min: 21 (0.0823529)
      max: 255 (1)
      mean: 80.4196 (0.315371)
      standard deviation: 54.9377 (0.215442)
      kurtosis: 2.93417
      skewness: 1.95544
      entropy: 0.853176
  Image statistics:
    Overall:
      min: 21 (0.0823529)
      max: 255 (1)
      mean: 105.074 (0.412056)
      standard deviation: 58.8639 (0.230839)
      kurtosis: 1.37788
      skewness: 1.48073
      entropy: 0.897856
  Rendering intent: Perceptual
  Gamma: 0.454545
  Chromaticity:
    red primary: (0.64,0.33,0.03)
    green primary: (0.3,0.6,0.1)
    blue primary: (0.15,0.06,0.79)
    white point: (0.3127,0.329,0.3583)
  Alpha color: grey74
  Background color: white
  Border color: srgb(223,223,223)
  Transparent color: none
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 70x46+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG
  Quality: 92
  Orientation: Undefined
  Properties:
    jpeg:colorspace: 2
    jpeg:sampling-factor: 1x1,1x1,1x1
    signature: aea65c9b557d779d142f26d04abe7008bab50f1e9647faae20afdcc6c15140d5
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 2.65KB
  Number pixels: 3.22K
  User time: 0.000u
  Elapsed time: 0:01.000
  Version: ImageMagick 7.0.4-8 Q16 x86_64 http://imagemagick.org 

Note, the image signature is generated from the pixel components, not the image metadata.

To get the print size in inches of an image at 72 DPI, use:

$ magick identify -format "%[fx:w/72] by %[fx:h/72] inches" document.png
8.5 x 11 inches 

The depth and dimensions of a raw image must be specified on the command line:

$ magick identify -depth 8 -size 640x480 image.raw
image.raw RGB 640x480 sRGB 9kb 0.000u 0:01 

Here we display the image texture features, moments, perceptual hash, and the number of unique colors in the image:

$ magick identify -verbose -features 1 -moments -unique image.png

To display the convex hull and minimum bounding box attributes of the image, use:

magick identify -define identify:convex-hull=true image.png

Here is a special define that outputs the location of the minimum or maximum pixel of the image:

magick identify -precision 5 -define identify:locate=maximum -define identify:limit=3 image.png

You can find additional examples of using magick identify in Examples of ImageMagick Usage.

Option Summary

The magick identify command recognizes these options. Click on an option to get more details about how that option works.

Option Description
-alpha on, activate, off, deactivate, set, opaque, copy", transparent, extract, background, or shape the alpha channel
-antialias remove pixel-aliasing
-authenticate value decrypt image with this password
-auto-orient automagically orient image
-channel type apply option to select image channels
-clip clip along the first path from the 8BIM profile
-clip-mask filename associate clip mask with the image
-clip-path id clip along a named path from the 8BIM profile
-colorspace type set image colorspace
-crop geometry crop the image
-debug events display copious debugging information
-define format:option define one or more image format options
-density geometry horizontal and vertical density of the image
-depth value image depth
-endian type endianness (MSB or LSB) of the image
-extract geometry extract area from image
-features distance analyze image features (e.g. contract, correlations, etc.).
-format string output formatted image characteristics
-gamma value level of gamma correction
-grayscale method convert image to grayscale
-help print program options
-interlace type type of image interlacing scheme
-interpolate method pixel color interpolation method
-limit type value pixel cache resource limit
-list type Color, Configure, Delegate, Format, Magic, Module, Resource, or Type
-log format format of debugging information
-mask filename associate a mask with the image
-moments display image moments and perceptual hash.
-monitor monitor progress
-negate replace each pixel with its complementary color
-ping by default, efficiently determine certain image characteristics by only reading the requisite image metadata. To accurately identify all the image metadata and pixel characteristics, use +ping.
-precision value set the maximum number of significant digits to be printed
-quiet suppress all warning messages
-regard-warnings pay attention to warning messages.
-respect-parentheses settings remain in effect until parenthesis boundary.
-sampling-factor geometry horizontal and vertical sampling factor
-set attribute value set an image attribute
-size geometry width and height of image
-strip strip image of all profiles and comments
-unique display image the number of unique colors in the image.
-units type the units of image resolution
-verbose print detailed information about the image
-version print version information
-virtual-pixel method access method for pixels outside the boundaries of the image