Skip to content
Search

ImageMagick

lastmod 2026-02-18created 2014-03-1025 edits

ImageMagick is free software used to create or edit graphic images. ImageMagick can read, convert, and write most image formats. It can apply various effects, including cropping image edges and changing colors, and can rotate and combine images, insert text, draw lines, polygons, ellipses, and Bézier curves, stretch images, and so on.

ImageMagick® is a software suite to create, edit, compose, or convert bitmap images. It can read and write images in a variety of formats (over 100) including DPX, EXR, GIF, JPEG, JPEG-2000, PDF, PNG, Postscript, SVG, and TIFF. Use ImageMagick to resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves.

The functionality of ImageMagick is typically utilized from the command line or you can use the features from programs written in your favorite language. Choose from these interfaces: G2F (Ada), MagickCore (C), MagickWand (C), ChMagick (Ch), ImageMagickObject (COM+), Magick++ (C++), JMagick (Java), L-Magick (Lisp), Lua, NMagick (Neko/haXe), Magick.NET (.NET), PascalMagick (Pascal), PerlMagick (Perl), MagickWand for PHP (PHP), IMagick (PHP), PythonMagick (Python), RMagick (Ruby), or TclMagick (Tcl/TK). With a language interface, use ImageMagick to modify or create images dynamically and automagically.

ImageMagick is free software delivered as a ready-to-run binary distribution or as source code that you may use, copy, modify, and distribute in both open and proprietary applications. It is distributed under the Apache 2.0 license, approved by the OSI and recommended for use by the OSSCC.

How to Install

On CentOS, install it as follows.

$ yum install ImageMagick

Example

Example of the JPEG quality Convert

  • Download: Imagemagick_-_jpeg_convert_sample.zip

Sample code for a Windows batch file that converts JPEG quality in bulk using ImageMagick is as follows.

SET MGD_IMAGE_DIR=.\convert_image
SET CONVERTER_NAME=convert.exe
SET CONVERTER_OPTION=-resize 260x350 -quality 92 -depth 24
SET TEMP_DIR=.\.temp
SET OUTPU_EXT=.jpg
SET OUTPUT_FILE=mgd-search.ggii

IF NOT EXIST "%TEMP_DIR%" MKDIR "%TEMP_DIR%"
FOR /R "%MGD_IMAGE_DIR%" %%i IN (*.jpg *.JPG) DO "%CONVERTER_NAME%" %CONVERTER_OPTION% "%%i" "%TEMP_DIR%\%%~ni%OUTPU_EXT%"

Concat image

Images can be concatenated as follows.

$ convert image1.jpeg image2.jpeg image3.jpeg -append output.jpeg

For vertical stacking (top to bottom):

$ convert -append 1.jpg 2.jpg out.jpg

For horizontal stacking (left to right):

$ convert +append 1.jpg 2.jpg out.jpg

Convert format

For a simple format conversion, passing just the INPUT and OUTPUT is enough.

$ convert image.jpeg image.png

Explicit way:

$ convert image.jpeg -format png image.png

Crop Image

then you could do it with (width x height + left + top / wxh+l+t format):

convert image.jpg -crop 703x470+3+5 output.jpg

How to create an icon file

convert -define icon:auto-resize=16,32,54,128,256 -compress zip logo-1024.png favicon.ico

Other commands for reference:

convert -background transparent -define 'icon:auto-resize=16,24,32,64' logo.svg favicon.ico
convert -transparent white -format ico -resize 64x64 logo.svg favicon.ico

Image rotation

convert input_image.jpg -rotate 180 output_image.jpg

See also

  • Cascade - GPU-accelerated node-based image editor
  • ImaginAIry - Edit images with AI
  • BackgroundRemover - Open-source background removal for images/videos
  • pypipo - Image processing technique that automatically converts images to paint-by-number (PIPO painting)
  • img2pdf - Converts images to PDF.
  • Vert - Open-source self-hostable file converter
  • slimg - Image optimization CLI written in Rust

Favorite site

author Zer0 sitemap