Preview Images on X with ImageMagick display
You will finish with a repeatable way to open an image or image sequence in an X window, resize the view without rewriting the source, and diagnose the two common problems: no usable X display and a file that is not what you thought it was. The examples target ImageMagick 6.9.12-98 Q16, supplied here by imagemagick-6.q16 version 8:6.9.12.98+dfsg1-5.2ubuntu0.1~esm13.
The route
Jump straight to the step you need, or tick off Done means at the end.
Allow about ten minutes. You need a readable image file, the display-im6.q16 command, and access to an X server. These are ordinary user commands. Do not use sudo just to view a personal image.
1. Confirm the installed command and X session
Check which executable will run and ask it for its version:
$ command -v display-im6.q16
/usr/bin/display-im6.q16
$ display-im6.q16 -version
Version: ImageMagick 6.9.12-98 Q16 x86_64
The local package also provides the aliases display and display-im6. The manual documents display-im6.q16 as the canonical command, so use that spelling in scripts and troubleshooting notes. The command talks to the X server selected by the DISPLAY environment variable:
$ printf 'DISPLAY=%s\n' "${DISPLAY:-<unset>}"
DISPLAY=:0
If DISPLAY is unset, or points to a session you cannot access, the viewer cannot create its window. In an SSH session, use a deliberately configured X forwarding session rather than copying a random value from another login. A value such as :0 is an example, not a universal setting.
Checkpoint
You have a real image path and a usable X session. If this check fails, stop here and fix the session before changing image options.
2. Open one image
Pass the image path as the final argument. ImageMagick detects the format from the file's magic number, so a misleading suffix does not by itself decide how the file is read:
$ display-im6.q16 /path/to/photo.jpg
A window should appear. The manual's mouse controls are useful when the image is larger than the window: press mouse button 1 to map or unmap the Command widget, and press and drag with button 2 to magnify a region. Button 3 loads an image from a visual image directory. Close the window using its normal window-manager control when you are finished.
To check the file before opening it, use the separate identify command if it is installed:
$ identify /path/to/photo.jpg
/path/to/photo.jpg JPEG 2400x1600 2400x1600+0+0 8-bit sRGB 1.2MiB 0.000u 0:00.000
The size, format, and metadata wording can vary. The useful part is that identify can read the file and reports dimensions. It does not prove that a remote X server is reachable.
3. Fit a large image without changing it
Use -geometry to set the window's preferred size and location. A percentage is a practical starting point for a large image:
$ display-im6.q16 -geometry 50% /path/to/photo.jpg
This controls the displayed window preference. It is not an export operation and does not overwrite the input. If you need a fixed maximum size, use a geometry such as 1200x900; the viewer will use the requested geometry for the image window.
Do not confuse that with -resize. The manual lists -resize as an image operator, so it changes the image held by the viewer. That can be useful for inspection, but it is not a safe substitute for making a thumbnail file. If you need a persistent derivative, make that a separate, deliberate conversion step and choose a new destination first.
4. View several files as an image sequence
Give the command more than one input when you want one viewer session to hold an image sequence:
$ display-im6.q16 /path/to/frame-01.png /path/to/frame-02.png /path/to/frame-03.png
Use the Command widget to move through the loaded images. For an animated or repeating sequence, the installed manual documents -delay in centiseconds and -loop for the number of iterations:
$ display-im6.q16 -delay 10 -loop 0 /path/to/frame-*.png
Shell globbing happens before ImageMagick starts. If the pattern matches nothing, the shell may pass the literal pattern to the program, so check the input list first when a sequence matters:
$ printf '%s\n' /path/to/frame-*.png
/path/to/frame-01.png
/path/to/frame-02.png
/path/to/frame-03.png
Checkpoint
The list printed actual files, and the window opens with the expected number of images. A sequence viewer reads its inputs; it does not need elevated privileges.
5. Display vector artwork at its intended density
The manual says that display defaults to the X screen resolution. For a vector input, explicitly set a density when physical sizing matters:
$ display-im6.q16 -density 72 /path/to/drawing.svg
-density is an image setting and accepts a geometry value. The documented 72 DPI example is a useful baseline, not a promise that every SVG's internal dimensions will look identical across viewers. If the result is unexpectedly small or large, inspect the source dimensions and try an explicit density rather than repeatedly guessing with window geometry.
6. Handle X and input failures safely
If the command reports that it cannot open the display, verify the session without changing anything:
$ printf 'DISPLAY=%s\n' "${DISPLAY:-<unset>}"
$ test -n "$DISPLAY" && echo 'DISPLAY is set'
$ identify /path/to/photo.jpg
A successful identify result separates an image-reading problem from an X connection problem. If you are on a graphical desktop, run the viewer from a terminal inside that desktop. If you are remote, establish approved X forwarding or use a non-GUI inspection tool; do not weaken X authentication or copy another user's cookie.
If ImageMagick rejects the input, check the path and permissions:
$ ls -l /path/to/photo.jpg
$ test -r /path/to/photo.jpg && echo readable
A readable file can still be corrupt or an unsupported format. identify is a useful first check. Keep any error text when asking for help, including the exact command and the ImageMagick version.
7. Avoid accidental writes
Most commands in this guide only read inputs and open a window. Be cautious with options that do write or alter the image in memory. The manual lists -write as an image setting, and shell redirection can truncate a destination before a later command has succeeded.
Warning
Do not test an output operation against the original file. Choose a new path, check that it is not already useful, and use a temporary name until the result has been inspected. If you did create an unwanted derivative, remove only that known derivative after checking its path. There is no undo for deleting the wrong file.
The -authenticate option accepts a password for decrypting an image. Do not put such a password in shell history, a shared process list, or a pasted diagnostic. Use the machine's approved secret-handling method if you genuinely need to open an encrypted image.
Done means
display-im6.q16 -versionidentifies the installed ImageMagick 6 build.DISPLAYpoints to an X session you are authorised to use.- A single image opens, or a checked list of sequence files opens, without
sudo. -geometryis used for a viewing preference, while-densityis used when vector resolution needs control.- Input files remain untouched and any output path is separate, deliberate, and checked before writing.