Skip to content

ImageMagick

Information

Program info

  • See ImageMagick version:

      convert -version
  • Show available lists:

      convert -list list
  • Show available alpha compositions:

      convert -list compose
  • Show supported fonts:

      convert -list font
  • Show supported formats:

      convert -list format

File info

  • Get information about file:

      identify image.png

Convert

  • Rotate image by some degrees:

      convert input.png -rotate 10 output.png
  • Remove image profiles (EXIF, ICC, etc.) from an image:

      convert input.jpg -strip output.jpg

    or (multiple images):

      mogrify -strip *.jpg
  • Pixel out an image:

      convert input.jpg -scale 25% -scale 400% output.jpg
  • Blur an image:

      convert input.jpg -blur 0x8 output.jpg

    or (for large images):

      convert input.jpg -filter Gaussian -resize 25% -define filter:sigma=2.5 -resize 400% output.jpg
  • Convert image to grayscale:

      convert input.jpg -colorspace Gray output.jpg
  • Simulate a charcoal drawing:

      convert input.jpg -charcoal 1.2 output.jpg
  • Transform image to black and white:

      convert input.jpg -monochrome output.jpg
  • Replace each pixel with its complementary color:

      convert input.jpg -negate output.jpg

Resizing or scaling

  • Ignore aspect ratio:

      convert input.jpg -resize 64x64\! output.jpg
  • Only shrink larger images:

      convert input.jpg -resize 64x64\> output.jpg
  • Only enlarge smaller images:

      convert input.jpg -resize 64x64\< output.jpg
  • Fill area:

      convert input.jpg -resize 64x64^ -gravity center -extent 64x64 output.jpg
  • Percentage resize:

      convert input.jpg -resize 50% output.jpg
  • Resize using a pixel area count maximum:

      convert input.jpg -resize 4096@ output.jpg
  • Resize using a pixel area count minimum:

      convert input.jpg -resize 4096@\> output.jpg

Thumbnails and framing

  • Create a thumbnail in GIF format:

      convert input.jpg -format gif -thumbnail 100x100 thumb.gif
  • Create thumbnails in a subdirectory (./thumbs):

      mogrify -path thumbs -format gif -thumbnail 100x100 *.jpg
  • Resize the thumbnail to fit:

      convert input.jpg -thumbnail '100x100>' thumb.jpg
  • Cut the thumbnail to fit:

      convert input.jpg -thumbnail 100x100^ -gravity center -extent 100x100 thumb.jpg
  • Create multi-resolution favicon:

      convert input.png -alpha off -resize 256x256 \
        -define icon:auto-resize="256,128,96,64,48,32,16" favicon.ico

Photo handling

  • Average several photos:

      convert *.jpg -colorspace sRGB -evaluate-sequence median output.jpg
  • Create tilt-shift effect:

      convert input.jpg sigmoidal-contrast 15x30% \
        \( +clone -sparse-color Barycentric '0,0 black 0,%h gray80' -solarize 50% -level 50%,0 \) \
        -compose Blur -set option:compose:args 10 -composite output.jpg

    or (faster):

      convert input.jpg -sigmoidal-contrast 15x30% \
        \( +clone -sparse-color Barycentric '0,0 black 0,%h gray80' -solarize 50% -level 50%,0 -write mpr:blur_map \) \
        -compose Blur -set option:compose:args 10x0 -composite mpr:blur_map \
        compose Blur -set option:compose:args 0x10 -composite output.jpg
  • Create a traditional film-like double exposure:

      convert input_1.jpg input_2.jpg -average output.jpg

References