LinuxCommandLibrary

ImageMagick

Convert, edit, compose, or display images

SYNOPSIS

General syntax:
magick [options] input_file [operations] output_file

Examples of common usage:
magick convert input.jpg -resize 50% output.png
magick mogrify -resize 50% *.jpg
magick identify -verbose image.png

PARAMETERS

-resize geometry
    Scale an image using a specified geometry. Examples: 50%, 120x120> (shrink to fit), x200 (height 200, width auto).

-quality value
    Set the compression level for formats like JPEG, MIFF, or WebP. Value ranges from 0 (lowest quality) to 100 (highest quality).

-format string
    Output specific image attributes. Commonly used with identify to extract metadata or properties.

-background color
    Set the background color, used for operations like compositing or transparent image resizing.

-alpha option
    Control the image's alpha (transparency) channel. Options include On, Off, Set, Remove, Extract, etc.

-rotate degrees
    Rotate an image by the specified number of degrees clockwise.

-crop geometry
    Cut out a rectangular region of the image. Geometry specifies width, height, and offset.

-gravity direction
    Set the direction for operations like cropping or text placement (e.g., NorthWest, Center, SouthEast).

-monochrome
    Transform the image to black and white, effectively reducing it to a bi-level image.

-level black,white[%]
    Adjust the image's levels by mapping the specified black and white points to the full dynamic range.

-strip
    Strip all profiles and comments (e.g., EXIF, IPTC, XMP) from the image, reducing file size.

-compress type
    Set the image compression type for the output format (e.g., JPEG, LZW, None).

-verbose
    Print detailed information about the image file being processed or identified.

-version
    Display the ImageMagick version, copyright, and feature configuration.

-help
    Display command usage and available options for the specific subcommand or overall utility.

DESCRIPTION

ImageMagick is a free and open-source software suite for displaying, converting, and editing raster image files and vector image files. It supports over 200 image file formats including PNG, JPEG, GIF, TIFF, DPX, EXR, WebP, Postscript, PDF, and SVG. It can resize, rotate, crop, flip, or transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses, and Bézier curves.

ImageMagick's functionality is primarily accessed from the command line, though it also offers programming interfaces for various languages like Perl, PHP, Python, and Ruby. Its versatility makes it an essential tool for web development, desktop publishing, and automated image manipulation tasks, commonly used for generating thumbnails, watermarking, creating image collages, and efficient format conversion.

CAVEATS

  • Performance and Resource Usage: Complex operations or large images can consume significant CPU and memory, potentially leading to slow processing or system instability on resource-constrained systems.
  • Security: Processing untrusted image files can pose security risks (e.g., known vulnerabilities like 'ImageTragick'). It's crucial to keep ImageMagick updated and be cautious when handling external inputs, potentially using a restricted environment or sanitization.
  • Complexity: ImageMagick offers a vast array of options and its order of operations matters, which can make it challenging for new users to master.
  • Delegate Libraries: ImageMagick relies on numerous external delegate libraries for format support. Missing or misconfigured delegates can limit functionality or cause errors.

SCRIPTING INTEGRATION

ImageMagick is highly scriptable and commonly used in shell scripts, and via bindings in programming languages such as Python (Wand), PHP (Imagick), and Ruby (RMagick) for automated image processing workflows.

QUANTUM DEPTH

ImageMagick can be compiled with different quantum depths (e.g., 8-bit, 16-bit, 32-bit per color channel), affecting memory usage and color precision. Higher quantum depths allow for more accurate color representation but consume more resources.

DELEGATES AND DEPENDENCIES

The suite relies on external libraries (delegates) such as libjpeg, libpng, libtiff, FreeType, and Ghostscript, to handle various image formats and functionalities. The availability of these delegates determines ImageMagick's full capabilities.

HISTORY

ImageMagick was first released in 1990 by John Cristy at DuPont. Initially developed for 24-bit images on a workstation, it quickly evolved into a robust, cross-platform image processing suite. Its development was driven by the need for flexible image manipulation in scientific and graphic design contexts. Over the decades, it has undergone significant architectural changes; notably, version 7.x consolidated many standalone utilities (like convert, mogrify, identify) under a unified magick command-line tool, simplifying its usage and enhancing internal consistency. Its open-source nature has fostered a large community, contributing to its continuous improvement and widespread adoption.

SEE ALSO

convert(1), mogrify(1), identify(1), display(1), compare(1), GraphicsMagick(1), ffmpeg(1), exiftool(1)

Copied to clipboard