display Command in Linux



The Linux display command displays the image or image sequence on the X server. It is also used for batch processing and scripting. An X server is a software component of the X Window system that creates graphical user interfaces on bitmap displays.

The display command is a part of the ImageMagick suite of tools that primarily display images or image sequences through the terminal and perform various operations.

Table of Contents

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

Prerequisites to Use the display Command

The display command line tool is included in the ImageMagick tool suite. So, to use this command, the ImageMagick needs to be installed. In many Linux distributions, it comes by default, however, if it is not, then install it using the instructions given below −

To install ImageMagick in Ubuntu, Debian, and other Debian or Ubuntu-based distributions −

sudo apt install imagemagick

On RHEL and CentOS −

sudo yum install epel-release
sudo yum install ImageMagick

On Fedora −

sudo dnf install ImageMagick

On Arch Linux −

sudo pacman -S imagemagick

To install it on openSUSE, use −

sudo zypper install ImageMagick

To verify the installation, check the version −

convert --version

The display command is now available to use.

Syntax of display Command

The syntax for the Linux display command is as follows −

display [options] [image]

The [options] field is used to specify the options to change the display command output. While the [image] field is used to specify the image file.

display Command Options

The useful display command options are listed in the following table −

OptionsDescription
-alphaIt is used to activate, deactivate, on, off, extract, or shape the alpha channel
-anti-aliasingIt removes pixel aliasing
-backdropIt displays the image centered on the backdrop
-background colorIt changes the images background color by the color value
-border geometryIt adds a border to the image
-bordercolor colorIt adds color to the border
-coalesceIt merges the sequence of images
-comment stringIt annotates the image with a comment
-compress typeIt is used to specify the pixel compression type
-colorspace typeIt sets the color space of the image (CMYK, Gray, sRGB etc)
-+contrastIt enhances the image contrast with + and reduces it with -
-crop geometryIt crops the image
-despeckleIt reduces the speckle in the image
-delay centisecondsIt adds delay to display the image sequence
-enhanceIt applies a digital filter to enhance the image
-equalizeIt performs histogram equalization to the image
-extract geometryIt extracts specific areas of the image
-flattenIt flattens the sequence of images (GIF)
-flipIt flips the image vertically
-flopIt flips the image horizontally
-frame geometryIt frames the images with an ornamental frame
-gamma valueIt manages the gamma value (<1 darken the image: >1 lighten the image)
-helpIt displays the command help
-identifyIt identifies the characteristics of the image
-immutable typeIt prohibits the image edit
-label nameIt assigns a label to the image
-map typeIt transforms the image colors to the specified types
-negateIt replaces each pixel of the image with the complementary color
-profile filenameIt modifies the image profile (add, delete, apply)
-raise valueIt adds 3D edges to the image
-resample geometryIt changes the resolution of the image
-resize geometryIt resizes the image
-roll geometryIt rolls the image vertically or horizontally
-size geometryIt sets the width and height of the image
-thumbnail geometryIt creates a thumbnail of the image
-transparent colorIt makes the specified color transparent in the image
-trimIt trims the image's edges
-verboseIt displays details information about the image

Examples of display Command in Linux

This section focuses on various ways to use the display command in Linux −

  • Display Image from Terminal
  • Display a Sequence of Images
  • Display a Resized Image
  • Display a Cropped Image
  • Flip the Images
  • Rotate the Images
  • Display the Image Characteristics
  • Display the Image with 3D Edges
  • Display Image with a Border and Border Color
  • Change Display Window Title
  • Display the Thumbnail Size Image
  • Display the Monochrome Image
  • Display Image in Black & White

Display Image from Terminal

To display the image from the terminal, the display command is used. It opens the image using an X server.

Type the display command followed by the image name or path −

display image1.jpg
Display Image from Terminal display Command

Display a Sequence of Images

To display the sequence of images with a delay, use the -delay option with time in milliseconds.

In the following example, an image sequence will be displayed with a delay of 3 seconds −

display -delay 300 image1.jpg image2.jpg image3.jpg

Display a Resized Image

The -resize option is used with the desired size in pixels or percentages to display a resized image. For example, to display a resized image with a dimension of 460x210, use −

display -resize 460x210 image1.jpg
Display Resized Image display Command 1

In the same way, to resize an image by a percentage of the original size, use −

display -resize 60% image1.jpg
Display Resized Image display Command 2

Display a Cropped Image

Use the -crop option to display the cropped part of the image. The syntax of using -crop option with the display command is as follows −

display -crop [WidthxHeight+offset(top)+offset(left)] [File]

To display an image with a width of 300 and height of 240 pixels, use −

display -crop 300x240+0+0 image1.jpg
Display Cropped Image display Command 1

To specify the top offset of 160 and left offset of 80 pixels, use −

display -crop 300x240+160+80 image1.jpg
Display Cropped Image display Command 2

Flip the Images

The -flip option flips the image vertically −

display -flip image1.jpg
Flip Images display Command

Similarly, the -flop option flips the image horizontally −

display -flop image1.jpg

Rotate the Images

The -rotate option displays the rotated image at a specified angle. To display an image rotated at an angle of 30 degrees, use −

display -rotate 30 image1.jpg
Rotate Images display Command

Display the Image Characteristics

The -identify option is used to display the various characteristics of the image −

display -identify image1.jpg
Display Image Characteristics display Command

It displays the following information about the image −

Image Nameimage1.jpg
FormatJPEG
Dimensions600x450
Size + OffsetSize 600x450 Offset +0+0 (+0 top & +0 left)
8-bitColor Depth
Color SpacesRGB
File Size (bytes)38592 bytes
CPU time to process the image0.010 microseconds
The elapsed time to process the image0.004 Seconds

Display the Image with 3D Edges

To add 3D edges to the image, the -raise option is used with a value −

display -raise 12 image1.jpg
Display Image with 3D Edges display Command

Display Image with a Border and Border Color

The -border option is used to add a border to the image. For example, to add the border around all the sides of the image, use −

display -border 12 image1.jpg
Display Image with Border and Border Color 1

The default border color is #DFDFDF. To change the border color, -bordercolor option is employed −

display -border 12 -bordercolor "#B0E0E6" image1.jpg
Display Image with Border and Border Color 2

Change Display Window Title

To change the display windows title, the -title option is used −

display -title "My Image" image1.jpg
Change Display Window Title

Display the Thumbnail Size Image

To display the image in thumbnail size, use the -thumbnail option −

display -thumbnail 200x100 image1.jpg
Display Thumbnail Size Image

Display the Monochrome Image

To display the image in the monochrome format, the -monochrome option is used −

display -monochrome image1.jpg
Display Monochrome Image display Command

Display Image in Black & White

To display the image in black and white, use the -colorspace option −

display -colorspace Gray image1.jpg
Display Image in Black & White

Other commonly used color-spaces options are, CMYK, HSL, sRGB, HSV, HSB, HSI, Lab, Log, or YCBCr.

Conclusion

The display command in Linux displays the image on the X server. It is a part of the ImageMagick tools suite. It comes with tons of option to modify the image and display it.

Note that the display command does not alter the original image. It applies the changes and displays them.

This tutorial covered the display command syntax, its options, and its usage with various examples.