TOOL » IMAGE_MANIPULATOR » IMAGEMAGICK

Magick

Usage

Manipulate images.

shell
magick INPUT_OPTIONS INPUT_FILE OUTPUT_OPTIONS OUTPUT_FILE

Optimization

OptionDescription
-stripStrip image of all profiles and comments.
-trimTrim image edges.
-interlaceType of image interlacing scheme. none line plane JPEG GIF PNG.
-qualityValid only for JPEG or MPEG. 100 is lossless, 1 is worst quality.
-sampling-factorUsed by the JPEG encoder for chroma downsampling.

Basic operations

OptionDescription
-crop WxH+X+YCrop the image to size WxH, starting from (X;Y).
-resizeResize to WxH. By default it keeps the aspect ratio.
-rotateRotates the image by X degrees.
-flipMirror the image. ⇅
-flopMirror the image. ⇄
+repageReset virtual canvas.

Color manipulation

OptionDescription
-negateReplace each pixel with its complementary color.
-colorspaceSet the image colorspace. Ex: Gray
-thresholdApply simultaneous black/white threshold to the image. Ex: 50%

Border

OptionDescription
-bordercolor colorSet the border color. Color specification is like -fill.
-border geometrySurround the image with a border of color (set by -bordercolor).
-gravitySets the current gravity suggestion for various other settings and options. Check -list gravity for values.
-extentSet the image size and offset.

Advanced operations

OptionDescription
-alphaset: Activate alpha channel. background: Set any fully-transparent pixel to the background color, while leaving it fully-transparent.
-channel typeChange the channel subsequent operators will act.
-fuzzOn subsequent operators, colors within this distance are considered equal. Ex: 1%
-fillOn subsequent operators, color to use when filling a graphic primitive. Ex: none "#ffffff"
-floodfillStarting from (X;Y), any color that matches the color are filled with the -fill color. Ex: +0+0 white
-colorizeColorize the image using the color specified by the most recent -fill setting.
-opaqueChange this color to the fill color within the image.
-backgroundSet the background color. Ex: none
-flattenFlatten a sequence of images.
-blurReduce image noise and reduce detail levels. Ex: 0x1
-gaussian-blurReduce image noise and reduce detail levels. Ex: 0.05
-levelAdjust the level (contrast) of image channels. Ex: 10%,90%,2.0
-cloneMake a clone of an image (or images).
-composeSet the type of image composition.
-compositePerform alpha composition on two images and an optional mask.

Values

Format of values used on some options.

ColorDescription
#FFFFFFWhite color.
noneTransparent color.
GeometryDescription
10Width given, height automatically selected to preserve aspect ratio.
x10Height given, width automatically selected to preserve aspect ratio.
TypeDescription
RRed
GGreen
BBlue
AAlpha

Examples

Resize an image to an exact size, filling with transparent background instead of stretching.

shell
magick input.png -resize 1920x1080 -alpha background -gravity center -extent 1920x1080 output.png

Force output in a specific format by prepending the format in the ouput: format:output_file. Check all available formats with -list format. Bellow command is an example of getting a raw BGRA usable in mpv as overlay.

shell
magick -list format | less
magick input.webp \( +clone -alpha extract \) -channel RGB -compose multiply -composite BGRA:output

Darken an image by 30% (nice for smartphone wallpapers for better contrast with white text).

shell
magick input.png -fill black -colorize 30% output.png