mogrify
Modify images in place (batch processing)
TLDR
View documentation for the original command
SYNOPSIS
mogrify [options] input-file [input-file...]
PARAMETERS
-resize WxH
Resizes the image to the specified width (W) and height (H). Appending '!' forces exact dimensions, '>' resizes only if larger, '<' resizes only if smaller.
-rotate degrees
Rotates the image by the specified degrees. A positive value rotates clockwise.
-format type
Changes the image format to the specified type (e.g., JPEG, PNG, GIF). The original file extension will be updated.
-quality value
Sets the compression quality (0-100) for lossy formats like JPEG. Higher values mean better quality but larger file sizes.
-strip
Strips the image of any profiles, comments, and non-essential metadata, typically reducing file size.
-auto-orient
Automatically rotates the image to its correct orientation based on EXIF data, common in photos taken with digital cameras.
-path directory
Writes the modified image to the specified directory instead of overwriting the original file in its current location. This is a common safety measure.
-verbose
Prints detailed information about the image processing operations to standard output.
DESCRIPTION
The mogrify command is a powerful utility from the ImageMagick suite, designed for modifying images directly and in-place. Unlike its counterpart, convert, which creates a new image file as output, mogrify applies all specified operations to the original input file(s), overwriting them without prompting. This makes it particularly suitable for automating batch processing tasks, such as resizing entire directories of images, converting multiple files to a different format, or applying the same artistic effect across numerous pictures. Users can perform a wide array of transformations, including resizing, rotating, flipping, color adjustments, format conversions, and metadata stripping. Its efficiency in modifying images without generating intermediate files or requiring explicit output filenames streamlines workflows for web developers, photographers, and system administrators. However, its in-place nature means operations are irreversible by default, necessitating caution and often prior backups of original files.
CAVEATS
The primary caveat of mogrify is its destructive nature: it modifies images in-place, overwriting the original files. There is no built-in 'undo' function. Therefore, it is strongly recommended to:
1. Backup original files before running mogrify on critical data.
2. Test commands on a copy of the images first.
3. Use the -path option to write modified images to a different directory, effectively turning it into a non-destructive operation similar to convert, but with mogrify's batch processing capabilities.
<I>MOGRIFY</I> VS <I>CONVERT</I>
The fundamental difference between mogrify and convert (also part of ImageMagick) lies in how they handle output. mogrify modifies the input image file(s) in-place, overwriting the original. In contrast, convert requires an explicit output filename and creates a new image file, leaving the original intact. While convert is safer for single-image transformations due to its non-destructive nature, mogrify excels in batch processing scenarios where the intent is to update a large number of images directly.
HISTORY
Mogrify is an integral part of the widely acclaimed ImageMagick software suite, which was first publicly released in 1990. Developed by John Cristy, ImageMagick provides a comprehensive set of tools for creating, editing, composing, or converting bitmap images. Mogrify emerged as a specialized utility within this suite, offering the unique capability of applying image transformations directly to the source files, serving the need for efficient batch processing where creating new output files for every transformation would be cumbersome or inefficient. Its development has paralleled that of the broader ImageMagick project, continuously evolving to support new image formats and processing algorithms.