### Perspective Distortion Example Source: https://imagemagick.org/command-line-options Demonstrates how to apply perspective distortion to an image using a list of source and destination coordinates. Spaces are used to group coordinate pairs for readability. ```bash magick rose: -virtual-pixel black \ -distort Perspective '0,0,0,0 0,45,0,45 69,0,60,10 69,45,60,35' \ rose_3d_rotated.gif" ``` -------------------------------- ### Map Pixel Components Source: https://imagemagick.org/command-line-options Specify the order and repetition of pixel components for mapping. This example demonstrates mapping red and green components twice. ```bash magick input.png -map rgbr output.png ``` -------------------------------- ### List Supported Arguments Source: https://imagemagick.org/command-line-options Print a list of supported arguments for various ImageMagick options. Use '-list list' to get a complete listing of all available '-list' arguments. ```bash magick identify -list list ``` -------------------------------- ### Specify Red and Blue Channels Source: https://imagemagick.org/command-line-options Examples of how to select only the Red and Blue channels for subsequent operations using different formats. ```bash -channel Red,Blue ``` ```bash -channel R,B ``` ```bash -channel RB ``` ```bash -channel 0,2 ``` -------------------------------- ### Draw Bezier Curves Source: https://imagemagick.org/command-line-options These examples illustrate how to draw Bezier curves using the -draw option. Multiple four-point Bezier segments can be chained together to create complex curves. ```bash -draw 'bezier 20,50 45,100 45,0 70,50' ``` ```bash -draw 'bezier 70,50 95,100 95,0 120,50' ``` -------------------------------- ### Format Debug Log Source: https://imagemagick.org/command-line-options Specify the format for the log printed when the -debug option is active. This example shows how to log user CPU time, module, and event details. ```bash magick -debug coder -log "%u %m:%l %e" in.gif out.png ``` -------------------------------- ### Kmeans Color Reduction Example Source: https://imagemagick.org/command-line-options Performs iterative color reduction using the Kmeans algorithm. Specify the desired number of colors, iterations, and convergence tolerance. Seed colors can be provided to override quantization. ```bash -kmeans 5x300+0.0001 ``` ```bash -define kmeans:seed-colors="red;sRGB(19,167,254);#00ffff" ``` -------------------------------- ### Apply Morphology Method Source: https://imagemagick.org/command-line-options Applies a specified morphology method and kernel to the image. Refer to IM Usage Examples, Morphology for details. ```bash -morphology method kernel ``` -------------------------------- ### Specify Fill Color Source: https://imagemagick.org/command-line-options Examples of using the -fill option with different color specifications: a color name, a hex color, and an RGB value. Enclose specifications in quotes to avoid shell interpretation. ```bash -fill blue ``` ```bash -fill "#ddddff" ``` ```bash -fill "rgb(255,255,255)" ``` -------------------------------- ### Draw a Circle with Rounded Corners Source: https://imagemagick.org/command-line-options This example demonstrates drawing a circle with specified stroke and fill colors, and a defined stroke width. It uses the 'translate' primitive to simplify coordinate calculations for the circle's center and radius. ```bash magick -size 100x60 xc: -stroke SeaGreen -fill PaleGreen -strokewidth 2 -draw 'translate 50,30 circle 0,0 25,0' circle.gif ``` -------------------------------- ### Setting Area Limit for Disk Caching Source: https://imagemagick.org/command-line-options This example sets the maximum image area that can be processed in memory before it's automatically cached to disk. Use this to manage memory usage for large images. ```bash -limit area 10MB ``` -------------------------------- ### Tiled Perspective Distortion with Checkerboard Source: https://imagemagick.org/command-line-options Applies a perspective distortion to a checkerboard pattern, creating an infinitely tiled effect. This example uses EWA resampling for high-quality results, especially when minifying the image. ```bash magick -size 90x90 pattern:checkerboard -normalize -virtual-pixel tile \ -distort perspective '0,0,5,45 89,0,45,46 0,89,0,89 89,89,89,89' \ checks_tiled.jpg ``` -------------------------------- ### List available intensity methods Source: https://imagemagick.org/command-line-options Use the -list option with 'intensity' to display all supported methods for calculating pixel intensity values. ```bash magick -list intensity ``` -------------------------------- ### Get A4 Paper Size in Pixels Source: https://imagemagick.org/command-line-options Use this command to determine the pixel dimensions of a specified paper size at 72 DPI. ```bash magick xc: -format "%[papersize:a4]" info: ``` -------------------------------- ### Force Two Output Images with +adjoin Source: https://imagemagick.org/command-line-options Use +adjoin following -fft to force any image format to produce two output images (magnitude and phase), even if it supports multi-frame images. ```bash magick image.png -fft +adjoin fft_image.png ``` -------------------------------- ### Create Meta Channels from Gray Pixels Source: https://imagemagick.org/command-line-options Creates two meta channels and populates them with a copy of the gray pixels from an input image. This is useful for storing or manipulating intermediate image data. ```bash magick gray.pgm -channel-fx "gray=>meta, gray=>meta1" gray.tif ``` -------------------------------- ### ImageMagick -alpha on Source: https://imagemagick.org/command-line-options Enable the alpha channel. This is equivalent to the obsolete -matte operation. ```bash -alpha on ``` -------------------------------- ### Apply Image Preview Source: https://imagemagick.org/command-line-options Applies a specified preview type to an image. Common types include Gamma, JPEG, and Sharpen. Use '-list preview' for a full list. ```bash magick file.png -preview Gamma Preview:gamma.png ``` -------------------------------- ### ImageMagick -alpha activate Source: https://imagemagick.org/command-line-options Enable the image's transparency channel. Use this when you specifically need to preserve existing transparency that has been turned off. ```bash -alpha activate ``` -------------------------------- ### Determine Image Characteristics Efficiently Source: https://imagemagick.org/command-line-options Use the -ping option for a quick determination of essential image properties without fully decoding the image data. Use +ping to ensure accuracy. ```bash -ping ``` ```bash +ping ``` -------------------------------- ### Set Global Artifact for Image Properties Source: https://imagemagick.org/command-line-options Sets a global artifact that can be used to pass properties between images, even after the original image is modified or destroyed. This example uses the artifact to label an image with the size of a previously deleted image. ```bash magick rose: -set option:rosesize '%wx%h' -delete 0 \ label:'%[rosesize]' label_size_of_rose.gif ``` -------------------------------- ### Weighted Image Combination with Polynomials Source: https://imagemagick.org/command-line-options Combines multiple images using a weighted sum of polynomials. Weights should be fractions between -1 and 1, summing to 1. Exponents can be positive, negative, or zero. Use 'xc:somecolor' or 'null:' to add constants or white. ```bash magick image1.png -poly "0.5*image1^1 + 0.5*image2^1" result.png ``` ```bash magick image1.png image2.png -poly "0.5*image1^2 + 0.5*image2^2" squares.png ``` ```bash magick image1.png xc:black -poly "1.0*image1^1 + 0.5*xc:black^0" add_black.png ``` ```bash magick image1.png null: -poly "1.0*image1^1 + 0.5*null:^0" add_white.png ``` -------------------------------- ### Hide watermark within an image with offset Source: https://imagemagick.org/command-line-options Use the -stegano option to hide a watermark within an image. An offset can be specified to start hiding the watermark a certain number of pixels from the beginning of the image. This offset and the image size are crucial for recovering the steganographic image. ```bash display -size 320x256+35 stegano:image.png ``` -------------------------------- ### Listing Current Resource Limits Source: https://imagemagick.org/command-line-options This command displays the current resource limits configured for ImageMagick. It's useful for understanding the system's current constraints before applying new limits. ```bash identify -list resource ``` -------------------------------- ### Generate Multi-Image File with Scene Numbers Source: https://imagemagick.org/command-line-options This command demonstrates how to create a sequence of morphing images and save them into separate files, automatically numbering them using a printf-style format string in the filename. ```bash magick logo: rose: -morph 15 my%02dmorph.jpg ``` -------------------------------- ### Normalize Image Contrast Source: https://imagemagick.org/command-line-options Normalizes image contrast by stretching the min and max values to 0 and QuantumRange without data loss. This is equivalent to -contrast-stretch 0. ```bash magick -contrast-stretch 0 input.png output.png ``` -------------------------------- ### Image Conversion with Profile Application Source: https://imagemagick.org/command-line-options Performs image conversion while applying specified profiles. Note that conversions can be asymmetric and may yield unwanted results. ```bash magick CMYK.tif -profile "CMYK.icc" -profile "RGB.icc" RGB.tiff ``` -------------------------------- ### Generate Magnitude and Phase Images using -fft Source: https://imagemagick.org/command-line-options This command generates a two-frame MIFF image where the first frame is the magnitude and the second is the phase of the frequency domain representation. MIFF is recommended as it supports multi-frame images. ```bash magick image.png -fft fft_image.miff ``` -------------------------------- ### Mosaic Layer Method Source: https://imagemagick.org/command-line-options A simple alias for the -layers method with the 'mosaic' argument. ```bash -mosaic ``` -------------------------------- ### ImageMagick -alpha opaque Source: https://imagemagick.org/command-line-options Enable the alpha/matte channel and force it to be fully opaque. This ensures the image has an alpha channel but no transparency. ```bash -alpha opaque ``` -------------------------------- ### ImageMagick -alpha transparent Source: https://imagemagick.org/command-line-options Activate the alpha/matte channel and force it to be fully transparent. This creates a fully transparent image of the same size, retaining the original RGB data but making it invisible. ```bash -alpha transparent ``` -------------------------------- ### Composite Image with -draw Source: https://imagemagick.org/command-line-options Use the -draw option to composite one image onto another. Specify the composite operator, location, size, and source image filename. Use 0,0 for size to use the image's actual dimensions. ```bash -draw 'image SrcOver 100,100 225,225 image.jpg' ``` -------------------------------- ### Draw Reset with -draw Color Primitive Source: https://imagemagick.org/command-line-options Use the color primitive with the 'reset' method to recolor all pixels. ```bash -draw 'reset' ``` -------------------------------- ### Simulate Oil Painting Source: https://imagemagick.org/command-line-options The -paint option simulates an oil painting by replacing pixels with the most frequent color in a defined neighborhood. ```bash -paint radius ``` -------------------------------- ### Set Original Size Property and Resize Image Source: https://imagemagick.org/command-line-options Stores the original image dimensions as a property and then resizes the image. The original size can be accessed using format percent escapes. ```bash $ magick rose: -set origsize '%wx%h' -resize 50% \ -format 'Old size = %[origsize] New size = %wx%h' info: ``` -------------------------------- ### Specify Output Path Source: https://imagemagick.org/command-line-options Use the -path option to direct ImageMagick to write output images to a specific directory on disk. ```bash -path path ``` -------------------------------- ### Create Grayscale Images from RGB Channels Source: https://imagemagick.org/command-line-options Generates three separate grayscale images, one for each of the red, green, and blue channels. This is useful for analyzing individual color components. ```bash magick -channel-fx "red; green; blue" ``` -------------------------------- ### Set Coder Defines Source: https://imagemagick.org/command-line-options Use -define to set specific global settings for coders and decoders. Value is case-dependent. Use +define to remove definitions. ```bash magick bilevel.tif -define ps:imagemask eps3:stencil.ps ``` ```bash -define registry:temporary-path=/data/tmp ``` -------------------------------- ### Create a red/cyan stereo anaglyph Source: https://imagemagick.org/command-line-options The -stereo option composites two images to create a red/cyan stereo anaglyph. The second image (left side) is saved as the red channel, and the first image (right side) is saved as the green and blue channels. Red-green stereo glasses are required for viewing. ```bash # Example usage not provided in source, but describes functionality. ``` -------------------------------- ### Setting Memory and Map Limits Source: https://imagemagick.org/command-line-options This snippet demonstrates how to set specific limits for memory and memory-mapped file usage. Use this when you need to control the maximum amount of RAM or virtual memory ImageMagick can allocate for pixel storage. ```bash -limit memory 32MiB -limit map 64MiB ``` -------------------------------- ### Apply Threshold to Image Source: https://imagemagick.org/command-line-options Pixels exceeding the threshold are set to maximum, others to minimum. Threshold can be a percentage or absolute value. Use percentages for better portability. ```bash magick in.png -channel red -threshold 50% out.png ``` ```bash magick in.png -channel RGB -threshold 100% black.png ``` ```bash convert in.png -channel RGB -threshold -1 white.png ``` -------------------------------- ### Compare Image Differences Source: https://imagemagick.org/command-line-options Compares two same-sized images and annotates the difference. The -metric option specifies the comparison metric. ```bash magick image.png reference.png -metric RMSE -compare \ difference.png ``` ```bash magick image.png reference.png -metric RMSE -compare -format \ "%[distortion]" info: ``` -------------------------------- ### Generate Separate Magnitude and Phase Images using -fft Source: https://imagemagick.org/command-line-options This command generates two separate PNG images for the magnitude and phase components. This is useful when the output format does not support multi-frame images. ```bash magick image.png -fft fft_image.png ``` -------------------------------- ### Transforming Image to Monochrome Source: https://imagemagick.org/command-line-options Converts an image to black and white. ```bash magick input.png -monochrome output.png ``` -------------------------------- ### Shear Image with Different Order of Operations Source: https://imagemagick.org/command-line-options Demonstrates that the order of horizontal and vertical shear operations matters. The first command applies horizontal shear before vertical, while the second applies vertical before horizontal, resulting in different outputs. ```bash magick logo: -shear 20x0 -shear 0x60 logo-sheared.png ``` ```bash convert logo: -shear 0x60 -shear 20x0 logo-sheared.png ``` -------------------------------- ### ImageMagick -alpha set Source: https://imagemagick.org/command-line-options Activate the alpha/matte channel. If the channel was previously off, it resets to opaque. If the alpha channel was already on, this operation has no effect. ```bash -alpha set ``` -------------------------------- ### Stretch Contrast with Black and White Points Source: https://imagemagick.org/command-line-options Increases image contrast by stretching intensity values. It allows specifying the maximum number of pixels to black-out and white-out. ```bash magick -contrast-stretch 10%x5% input.png output.png ``` -------------------------------- ### Set GIF Animation Loop Source: https://imagemagick.org/command-line-options Add Netscape loop extension to a GIF animation. Set iterations to zero for infinite repeats, otherwise the animation repeats up to the specified number of times. ```bash magick animation.gif -loop 0 animated.gif ``` -------------------------------- ### Configure Fourier Transform Normalization Source: https://imagemagick.org/command-line-options By default, the FFT is normalized and the IFT is not. Use '-define fourier:normalize=forward' to explicitly normalize the FFT and unnormalize the IFT. ```bash magick image.png -define fourier:normalize=forward -fft fft_image.miff ``` -------------------------------- ### Draw Filltoborder with -draw Color Primitive Source: https://imagemagick.org/command-line-options Use the color primitive with the 'filltoborder' method to recolor neighboring pixels that are not the border color. ```bash -draw 'filltoborder' ``` -------------------------------- ### Draw Point with -draw Color Primitive Source: https://imagemagick.org/command-line-options Use the color primitive with the 'point' method to recolor a specific pixel at the given coordinates. ```bash -draw 'point' ``` -------------------------------- ### Mapping -evaluate to -function Sinusoid Source: https://imagemagick.org/command-line-options Demonstrates how -evaluate Sin and Cos operators can be represented using the -function Sinusoid operator. ```imagemagick -evaluate Sin freq | -function Sinusoid freq,0 ``` ```imagemagick -evaluate Cos freq | -function Sinusoid freq,90 ``` -------------------------------- ### Change Matte Value with -draw Matte Primitive Source: https://imagemagick.org/command-line-options Use the matte primitive with various methods (point, replace, floodfill, filltoborder, reset) to change the alpha channel value of pixels. ```bash -draw 'point' ``` ```bash -draw 'replace' ``` ```bash -draw 'floodfill' ``` ```bash -draw 'filltoborder' ``` ```bash -draw 'reset' ``` -------------------------------- ### Adjust Pixel Perception Source: https://imagemagick.org/command-line-options The -perceptible option modifies pixel values based on a threshold, setting them to epsilon or -epsilon if they are closer to those values. ```bash -perceptible epsilon ``` -------------------------------- ### Apply Affine Transformation Source: https://imagemagick.org/command-line-options Applies a transformation matrix to an image. This method is superseded by -distort 'AffineProjection'. ```bash magick -affine 2,2,-2,2,0,0 -transform bird.ppm bird.jpg ``` -------------------------------- ### Basic Resize Filters Source: https://imagemagick.org/command-line-options Lists common filter types used for basic image resizing operations. ```text Point Hermite Cubic Box Gaussian Catrom Triangle Quadratic Mitchell CubicSpline ``` -------------------------------- ### Process Image with Custom Filter Module Source: https://imagemagick.org/command-line-options Processes an image using a custom filter module and its arguments. The format is 'module arg1 arg2 ...'. ```bash magick image.png -process "Analyze" image_analyzed.png ``` -------------------------------- ### Simulate Motion Blur Source: https://imagemagick.org/command-line-options Simulates motion blur with a given radius, standard deviation (sigma), and angle. The angle indicates the direction from which the blur appears to originate. ```bash -motion-blur radius{xsigma}+angle ``` -------------------------------- ### Set Image Type Source: https://imagemagick.org/command-line-options Use the -type option to specify the image format, such as TrueColor or TrueColorAlpha. This can override the encoder's default choice for efficiency. ```bash magick bird.png -type TrueColor bird.jpg ``` -------------------------------- ### Draw Floodfill with -draw Color Primitive Source: https://imagemagick.org/command-line-options Use the color primitive with the 'floodfill' method to recolor neighboring pixels matching the target pixel's color. ```bash -draw 'floodfill' ``` -------------------------------- ### Normalize Image Contrast Source: https://imagemagick.org/command-line-options Increases image contrast by stretching intensity values to the full range. It black-outs at most 2% of pixels and white-outs at most 1%. This is equivalent to -contrast-stretch 2%x1% in recent versions. ```bash -normalize ``` -------------------------------- ### Rotate and Annotate Text with -draw Source: https://imagemagick.org/command-line-options Apply transformations like rotation before drawing text. Transformations are cumulative within a single -draw option. ```bash -draw "rotate 45 text 10,10 'Works like magick!'" ``` -------------------------------- ### Remove Page Settings Source: https://imagemagick.org/command-line-options Use the +page option to reset or remove any previously set page dimensions and offsets for an image. ```bash +page ``` -------------------------------- ### Set Image Color Depth Source: https://imagemagick.org/command-line-options Use -depth to specify the number of bits per channel for each pixel. Use +depth to return to the default value. ```bash -depth value ``` -------------------------------- ### Draw Replace with -draw Color Primitive Source: https://imagemagick.org/command-line-options Use the color primitive with the 'replace' method to recolor all pixels matching the target pixel's color. ```bash -draw 'replace' ``` -------------------------------- ### Mapping -evaluate to -function Polynomial Source: https://imagemagick.org/command-line-options Illustrates correspondences between -evaluate operators and their equivalent -function Polynomial forms. ```imagemagick -evaluate Set value | -function Polynomial value ``` ```imagemagick -evaluate Add value | -function Polynomial 1,value ``` ```imagemagick -evaluate Subtract value | -function Polynomial 1,-value ``` ```imagemagick -evaluate Multiply value | -function Polynomial value,0 ``` -------------------------------- ### Define a Circle Primitive Source: https://imagemagick.org/command-line-options This snippet shows the basic syntax for defining a circle primitive using the -draw option. It specifies the center coordinates and a point on the perimeter. ```bash -draw 'circle 100,100 150,150' ``` -------------------------------- ### Set Multiple PNG Chunk Profiles Source: https://imagemagick.org/command-line-options Adds multiple custom PNG chunks to an output file. Unique identifiers are used to distinguish between chunks of the same type. ```bash magick in.png -set profile PNG-chunk-b01:file01 \ -profile PNG-chunk-b02:file02 out.png ``` -------------------------------- ### Apply Contrast Twice Source: https://imagemagick.org/command-line-options Enhances image contrast by applying the -contrast option twice. This option increases intensity differences between lighter and darker elements. ```bash magick rose: -contrast -contrast rose_c2.png ``` -------------------------------- ### Mapping +level to -function Polynomial Source: https://imagemagick.org/command-line-options Shows the equivalence between the +level operator and its representation using the -function Polynomial operator. ```imagemagick +level black% x white% | -function Polynomial A,B ``` -------------------------------- ### Swap image positions in sequence Source: https://imagemagick.org/command-line-options Use -swap to exchange the positions of two images within the image sequence. For instance, -swap 0,2 swaps the first and third images. Use +swap to switch the last two images. ```bash -swap 0,2 ``` ```bash +swap ``` -------------------------------- ### Windowed Resize Filters Source: https://imagemagick.org/command-line-options Lists filter types that are typically windowed, often used with Bessel and Sinc filters. ```text Lanczos Hamming Parzen Blackman Kaiser Welsh Hanning Bartlett Bohman ``` -------------------------------- ### ImageMagick -affine for Translation Source: https://imagemagick.org/command-line-options Apply translation to an image by specifying the displacement tx and ty. The scaling factors sx and sy are set to 1, and the rotation components are set to 0. ```bash -affine 1,0,0,1,tx,ty ``` -------------------------------- ### Apply Unsharp Mask Source: https://imagemagick.org/command-line-options Sharpen an image using the -unsharp option with radius, sigma, gain, and threshold parameters. Sigma is the most important for determining the sharpening amount. ```bash -unsharp radius{xsigma}{+gain}{+threshold} ``` -------------------------------- ### ImageMagick -affine for Scaling Source: https://imagemagick.org/command-line-options Use this option to scale an image by specifying the scaling factors sx and sy in the x and y directions, respectively. The translation coefficients tx and ty default to 0,0 if omitted. ```bash -affine sx,0,0,sy ``` -------------------------------- ### Add or Remove Image Profiles Source: https://imagemagick.org/command-line-options Manages ICM, IPTC, or generic profiles in an image. Use '-profile filename' to add and '+profile profile_name' to remove. ```bash magick image.png -profile "path/to/profile.icc" image_with_profile.png ``` ```bash magick image.png +profile "IPTC,*" image_without_iptc.png ``` ```bash magick +profile "!xmp,*" image_without_all_but_xmp.png ``` -------------------------------- ### Resize and Extent Image to Fit Display Source: https://imagemagick.org/command-line-options Reduces or expands a JPEG image to fit a display size, centering it on a canvas if aspect ratios don't match. Ensures output quality with -quality 92. ```bash magick input.jpg -resize 800x600 -background black -compose Copy \ -gravity center -extent 800x600 -quality 92 output.jpg ``` -------------------------------- ### Set Filename Property for Dynamic Output Filename Source: https://imagemagick.org/command-line-options Sets a property that is used to dynamically construct the output filename, incorporating image dimensions. ```bash magick rose: -set filename:mysize '%wx%h' 'rose_%[filename:mysize].png' ``` -------------------------------- ### Set Font Pointsize Source: https://imagemagick.org/command-line-options Specify the point size for PostScript, X11, or TrueType fonts using the -pointsize option. ```bash -pointsize value ``` -------------------------------- ### Convert Image to Rec709Luminance Grayscale Source: https://imagemagick.org/command-line-options Converts an image to Rec709Luminance grayscale using the -grayscale option. This is equivalent to setting the colorspace to LinearGray. ```bash magick in.png -grayscale Rec709Luminance out.png ``` ```bash magick in.png -colorspace LinearGray out.png ``` -------------------------------- ### Set PNG Chunk Profile Source: https://imagemagick.org/command-line-options Injects a custom PNG chunk into the output file. The chunk data is read from a specified file, and the location (before PLTE, middle, or end) is indicated by a flag. ```bash magick in.png -set profile PNG-chunk-x: out.png ``` -------------------------------- ### Specify Dimensions for Raw Images Source: https://imagemagick.org/command-line-options Sets the width and height for raw image formats like GRAY, RGB, or CMYK, which do not have embedded dimension information. An offset can be used to skip header data. ```bash magick -size 640x512+256 image.raw output.png ``` -------------------------------- ### Set font stretch style Source: https://imagemagick.org/command-line-options Use -stretch to suggest a stretch style for fonts. Available options include Any, Condensed, Expanded, ExtraCondensed, ExtraExpanded, Normal, SemiCondensed, SemiExpanded, UltraCondensed, and UltraExpanded. Use -list stretch to print a complete list. ```bash # Example usage not provided in source, but lists valid styles. ```