identify Command in Linux



The identify command in Linux displays the format or characteristics of one or more images. It is a part of the ImageMagick suite of tools. Apart from displaying information in image format, it also reports whether an image is corrupt.

The information the identify command returns is image number, name, height, width, image format, number of bytes, number of colors, and number of seconds the command takes to read the image.

Table of Contents

Here is a comprehensive guide to the options available with the identify command −

Prerequisites to Use identify Command

By default, the identify command may not be available in Linux. For verification, use the following command −

identify -version
identify Command in Linux1

If the above command shows a version, the identify command is installed. If it does not show the version then install it using the instructions mentioned below.

The identify tool is a part of the imagemagick suite. The imagemagic is a powerful open-source package that offers various tools to create, manipulate and convert images.

To install the imagemagick on Ubuntu, Kali Linux, Raspberry Pi OS, Debian, and Debian-based distributions, use the command given below −

sudo apt install imagemagick

To install it on Arch Linux, use −

sudo pacman -S imagemagick6

Syntax of identify Command

The syntax of the Linux identify command is as follows −

identify [options] [file]

The [options] field is used to use various options to identify command offers. The [file] field is used to specify the input image file.

Note − The identify command is entirely read-only. Some options may appear to modify the image. But the identify command does not change the image, it makes changes in the memory and shows the output. For example, the -crop option cuts the image in memory and reports the details of the modified image without affecting the original file.

Options of identify Command

The options for the identify command are listed below −

Options Description
-alpha To control the alpha channel: on, off, set, opaque, transparent, extract, backgroun, or shape
-antialias To remove pixel aliasing (smooth jagged edges)
-authenticate password To use the password to decrypt the image
-channel type To apply an option to specific image channels (like red, green, blue, and alpha)
-clip To clip the image along the first path found in the 8BIM profile
-clip-mask filename To associate a clip mask (stored in a separate file) with the image
-clip-path id To clip the image along a named path from the 8BIM profile
-colorspace type To change the image's colorspace (e.g., RGB, CMYK)
-crop geometry To crop the image to a rectangular region as defined by the geometry
-define format:option To set one or more image format-specific options
-density geometry To define the horizontal and vertical density (resolution) of the image
-depth value To set the bit depth of the image
-endian type To specify the byte order (endianness) of the image: MSB (most significant byte) or LSB (least significant byte)
-extract geometry To extract an area from the image based on geometry
-features distance To analyze image features like contrast, correlation, and more
-format "string" To output formatted image characteristics
-fuzz distance To define the color distance where colors are considered equal
-gamma value To apply gamma correction to adjust the brightness of the image
-interlace type To choose the interlacing scheme for the image (e.g., none, JPEG, PNG)
-interpolate method To define the pixel color interpolation method (e.g., NearestNeighbor, Bilinear, Bicubic)
-limit type value To set resource limits (e.g., memory, map, time, etc.) for processing the image
-list type To list supported types like Color, Configure, Delegate, Format, Magic, Module, Resource, or Type
-mask filename To associate a mask (stored in a file) with the image
-matte To store the matte (transparency) channel if present in the image
-moments To report statistical moments of the image (e.g., mean, variance)
-monitor To show progress during processing.
-ping To efficiently determine image attributes without fully loading the image
-precision value To set the maximum number of significant digits for printing image attributes
-quiet To suppress all warning messages during image processing
-regard-warnings To pay attention to warning messages (opposite of -quiet)
-respect-parentheses To ensure that settings remain in effect until the boundary of parentheses is reached
-sampling-factor geometry To define the horizontal and vertical sampling factors (for JPEG images)
-seed value To set the seed for generating pseudo-random numbers (used for dithering, etc.)
-set attribute value To set an image attribute (like image name, date, format)
-size geometry To define the width and height of the image
-strip To remove all profiles and comments from the image
-unique To display the number of unique colors in the image
-units type To set the units for image resolution (e.g., PixelsPerInch, PixelsPerCentimeter)
-verbose To print detailed information about the image and processing steps
-virtual-pixel method To define how to access pixels outside the image boundary (e.g., Background, Transparent, Tile)
-debug events To display detailed debugging information
-help To display program options
-list type To display a list of supported option arguments
-log format To define the format of debugging information
-version To display the version of the program

Examples of identify Command in Linux

This section demonstrates the usage of the Linux identify command with examples −

Displaying Information of a File

To display the information of an image file, use the identify command with the image file name −

identify image.jpg
identify Command in Linux2

The output shows the following attributes −

  • Format (JPEG)
  • Dimensions (2922x1862)
  • Size/Offset (2922x1862 / +0+0)
  • Color Depth (8-bit)
  • Color Space (sRGB)
  • Size (193746B)
  • CPU Time (0.000u)
  • Time Taken to Execute the Command (0:00.00)

Similarly, to display information of a bitmap image, use −

identify image.bmp
identify Command in Linux3

Displaying Verbose Information of a File

To display the detailed information of a file, use the -verbose option −

identify -verbose image.jpg
identify Command in Linux4

Displaying Progress while Loading Image

To display the progress of a loading image, use the -monitor option −

identify -monitor image.jpg
identify Command in Linux5

Displaying All the Supported Formats

To display all the supported formats, use the -list option with the format argument −

identify -list format
identify Command in Linux6

Displaying Information about all the Images in a Directory

To display information about all the images of the same extension, a wildcard can be used −

identify *.png

Displaying Information about a Cropped Image

To display the information of a cropped image, use the -crop option with the geometry specifying the crop section. For example, to split the image into 1920x1080 sections, use the identify command in the following way −

identify -crop 1920x1080 image.jpg
identify Command in Linux7

Displaying Help

To display the help about the identify command, use the -help option −

identify -help

Conclusion

The identify command in Linux is used to display the information of an image. It is a part of the ImageMagick suite.

To use the identify command on Linux, the imagemagick package must be installed. It is a handy tool to extract information about one or more images.

Advertisements