Loading...
X

ImageMagick guide: installing, using, and troubleshooting

Table of contents

1. How to install ImageMagick with all dependencies to support the maximum number of formats

1.1 What is Image Magic

1.2 Installing ImageMagick on Linux

1.3 How to fix “magick: command not found”

1.4 ImageMagick: use magick or convert command?

1.5 Why do animate, compare, composite, conjure, convert, display, identify, import, mogrify, montage, stream commands no longer work in ImageMagick

2. The structure of the magick command (ImageMagick)

2.1 ImageMagick Tools

2.2 Command line anatomy

2.3 Input file name

2.4 Command line options

2.5 Image Geometry

2.6 Output file name

2.7 The order of options matters in ImageMagick

2.8 How to specify color in ImageMagick

2.8.1 How to specify a color with transparency

2.9 Reference to file with option value

3. View image properties

3.1 How to get image properties

3.2 How to check the quality level of a JPG

3.3 How to find out the number of unique colors in an image

3.4 How to find out the size of an image

3.5 How to view image class and color space

3.6 How to view image depth

3.7 -format option arguments

3.8 Online service for displaying information about images

4. How to convert images to any formats in Linux

4.1 How to convert images on the Linux command line

4.2 How to convert PDF to JPG

4.3 How to convert JPG to PDF

4.4 Bulk image conversion

4.5 Convert images to all formats online

5. How to reduce image size. Bulk photo scaling and resizing on the command line

5.1 How to reduce image size

5.2 How to resize an image on the Linux command line

5.3 How to set image compression level in Linux command line

5.4 Bulk photo resizing on the command line

5.5 Compressing images without resizing them

5.6 How to prevent saving all pictures in one file

6. How to modify images on the Linux command line

6.1 Combining ImageMagick options and actions

6.2 How to extract an area of an image (cropping a picture)

6.3 How to apply an effect to an area of an image

6.4 How to imitate an oil painting

6.5 How to imitate a charcoal drawing

6.6 How to mimic a pencil sketch

6.7 How to make an image black and white

6.8 How to create an image negative

6.9 How to flip and flop images (vertical and horizontal image mirroring) on the Linux command line

6.10 How to rotate an image on the Linux command line

6.11 Rolling images. Film effect

6.12 How to simulate a Polaroid photo on the command line

6.13 How to reduce image noise on the Linux command line

6.14 How to increase image noise on the Linux command line

6.15 How to lighten or darken the edges of an image

6.16 How to create a border around an image

6.17 How to create a vignette

6.18 How to lighten an image. How to increase exposure

6.19 How to make an image darker. How to reduce exposure

7. How to composite and append images on the Linux command line (merge images)

7.1 How to put one image on top of another

7.2 How to append photos without overlay

7.3 How to append photos with space between them

8. How to create and convert animated GIF and video files

 

9. How to create images with ImageMagick on the command line

 

10. How to add text to images in ImageMagick

10.1 How to put text on image in ImageMagick

10.2 What to use to display text on images in ImageMagick – label:, caption: or -annotate?

10.3 Options for -annotate

10.4 How to add text to an image on the Linux command line

10.5 How to change font size in ImageMagick

10.6 How to change font color in ImageMagick

10.7 How to change font in ImageMagick

10.8 How to specify a font family

10.9 How to stroke text

10.10 How to make a font italic or oblique

10.11 How to change the text background color

10.12 How to change the origin of coordinates

10.13 How to enable or disable anti-aliasing when adding labels

10.14 How to set font thickness

10.15 How to change letter spacing

10.16 How to change word spacing

10.17 How to change line spacing

10.18 How to add rotated and slanted text to a photo

10.19 How to insert multiline text

10.20 How to use “label:” and “caption:” to add an image

10.21 How to use “label:” or “caption:” to add a caption without a background

10.22 How to add text with transparency to a photo. How to make a translucent background for the added text

10.23 Bulk add captions to images

10.24 How to add a watermark to a large number of images

10.25 How to choose the size of the text and its coordinates depending on the size of the image

11. ImageMagick Scripts

 

12. Using the ImageMagick library in various programming languages

 

13. ImageMagick troubleshooting

13.1 magick: no images found for operation…

13.2 magick: missing output filename `-identify' …

13.3 magick: MissingArgument …

13.4 magick: unrecognized option `-channel-extract'…

13.5 magick: unable to read font `Candice' @ warning/annotate.c/RenderType/1005.

13.6 Why are all files saved to one file

13.7 The option does not work, but no errors are shown

14. Reference information

14.1 All options of the magick command

14.2 List of supported formats and their brief description


1. How to install ImageMagick with all dependencies to support the maximum number of formats

What is Image Magic

Use ImageMagick to create, edit, compose, or convert digital images. It can read and write images in a variety of formats (over 200) including PNG, JPEG, GIF, WebP, HEIC, SVG, PDF, DPX, EXR and TIFF. ImageMagick can 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.

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 a derived Apache 2.0 license.

ImageMagick utilizes multiple computational threads to increase performance and can read, process, or write mega-, giga-, or tera-pixel image sizes. It runs on Linux, Windows, Mac OS X, iOS, Android OS, and others.

The authoritative ImageMagick web site is https://imagemagick.org. The authoritative source code repository is https://github.com/ImageMagick/ImageMagick.

The ImageMagick library can be used by other programming languages such as PHP (php-imagick), Python (pythonmagick), Ruby (Rmagick, ruby-rmagick).

Installing ImageMagick on Linux

Linux has ImageMagick, which supports hundreds of image formats and can convert an image from any format to any other.

The “convert” and “magick” utilities from the ImageMagick package do an excellent job of converting images (JPG and other formats).

On Debian, Linux Mint, Ubuntu, Kali Linux and their derivatives, you can install this package with this command:

sudo apt install imagemagick
# For SVG support
sudo apt install potrace

On Arch Linux, Manjaro, BlackArch and their derivatives, run the following commands to install:

sudo pacman -S imagemagick
# To support other formats such as JPEG (JPEG XL and JPEG2000), HEIF, DNG, SVG, WEBP, WMF, OpenRaster, OpenEXR, DJVU, install the following dependencies:
sudo pacman -S ghostscript libheif libjxl libraw librsvg libwebp libwmf libxml2 libzip ocl-icd openexr openjpeg2 djvulibre pango potrace

You can view the full list of supported formats with the command

magick -list format

Also at the end of the article is a table with a complete list of supported file formats and their brief description.

How to fix “magick: command not found”

If you encounter an error that the magick command is not found, then this means that:

  • imagemagick package not installed
  • installed imagemagick 6 or earlier

At the time of writing, the current version of ImageMagick is 7.*. But Debian and all derivative distributions use ImageMagick 6.*, which does not have the “magick” program. Therefore, if you get an error that the “magick: command found”, use the “convert” command instead.

ImageMagick: use magick or convert command?

In distributions that have ImageMagick 7.* in their repositories, both utilities are available after installing this package:

  • magick
  • convert

And you can use any of these commands to convert images and perform other actions.

But in reality, “convert” command is just a symbolic link to “magick”. At the same time, the syntax and options of these commands are the same, so you can use “convert” or “magick” as interchangeable commands to convert images, although in fact it will be the “magick” command that will be called simply because “convert” is a symbolic link to it.

In distributions with ImageMagick 6.*, only the “convert” program is available for converting images.

Why do animate, compare, composite, conjure, convert, display, identify, import, mogrify, montage, stream commands no longer work in ImageMagick

The following commands are also symbolic links to the magick command:

  • animate
  • compare
  • composite
  • conjure
  • convert
  • display
  • identify
  • import
  • mogrify
  • montage
  • stream

All these commands are now missing as separate programs, and calling them will run magick. For this reason, you may encounter the problem that although these utilities are present in the system, when you try to use them, errors will occur related to incorrect syntax or program options.

However, you can still call the deprecated utility, an example of calling the logo utility:

magick logo: logo.png

For more details, see the link: Porting Guide.

2. The structure of the magick command (ImageMagick)

ImageMagick Tools

ImageMagick tools are command line utilities, that is, programs without a graphical interface.

There are currently two tools left in the ImageMagick package:

  • magick is designed to convert between image formats, as well as image resizing, blurring, cropping, spot removal, smoothing, painting, flipping, merging, resampling and more.
  • magick-script, use this scripting language interpreter to convert between image formats, as well as image resizing, blurring, cropping, blemish removal, dithering, painting, reflection, merging, resampling, and more.

It has already been explained above that the previously existing utilities (namely animate, compare, composite, conjure, convert, display, identify, import, mogrify, montage, stream) in ImageMagick 7 (current version) remained only as symbolic links, and all their functionality has been transferred to magick.

However, Debian and all derivative distributions still use ImageMagick 6, with the old tools – be prepared for this.

Even in ImageMagick 7, you can call the old tool with a command like:

magick TOOL

For example:

magick animate
magick compare
magick composite
magick conjure
magick convert
magick display
magick identify
magick import
magick mogrify
magick montage
magick stream

But there is not much point in this, since all the functionality is collected in the magick utility.

Command line anatomy

The ImageMagick command line consists of

  1. one or more required input filenames.
  2. zero, one or more image parameters.
  3. zero, one or more image operators.
  4. zero, one or more image sequence operators.
  5. zero, one or more image stacks.
  6. zero or one output image filename

You can find a detailed explanation of each of the component parts of the command line in the following sections.

Input file name

The input file is the source file with which the program will perform various actions.

The input file can be specified in various ways. In addition, ImageMagick has special input file types.

ImageMagick extends the concept of an input filename to include, in addition to specifying a relative or absolute path to a file, the following:

  • using wildcards in file name (globbing)
  • explicit image format
  • using built-in images and templates
  • STDIN, STDOUT, and file descriptors
  • selecting specific frames from an image
  • image area selection
  • image resizing while reading
  • image cropping while reading
  • using a reference file with filenames

These extensions are explained in the next few paragraphs.

Using wildcard characters in a file name

In Linux shells, certain characters, such as the asterisk (*) and question mark (?), automatically cause lists of filenames to be generated based on pattern matches. This feature is known as globbing (wildcards). ImageMagick supports filename substitution for systems like Windows that don't natively support it. For example, let's say you want to convert 1.jpg, 2.jpg, 3.jpg, 4.jpg, and 5.jpg in the current directory to a GIF animation. You can conveniently access all JPEG files with this command:

magick *.jpg images.gif

Explicit image format

Images are stored in a variety of image formats, including the more well-known JPEG, PNG, TIFF, and more. ImageMagick needs to know the format of an image before it can be read and processed. Most formats have a signature inside the image that uniquely identifies the format. Otherwise, ImageMagick uses the filename extension to determine the format. For example, image.jpg or image.JPG tells ImageMagick that it is reading a JPEG image.

In some cases, the image may not contain a signature and/or the file name does not specify the image format. In these cases, you must specify an explicit image format. For example, let's say our image is called “image” and contains raw red, green, and blue intensity values. ImageMagick can't automatically detect the image format, so we explicitly set it:

magick -size 640x480 -depth 8 rgb:image image.png

Built-in images and templates

ImageMagick has a number of built-in images and templates. For example, to use the checkerboard pattern, use:

magick -size 640x480 pattern:checkerboard checkerboard.png

STDIN, STDOUT, and file descriptors

Linux and Windows allow you to pipe the output of one command to the input of another. ImageMagick allows you to read and write image data from the standard streams STDIN (standard input) and STDOUT (standard output), respectively, using the pseudo-filename - (hyphen). In this example, we are piping the output of “magick” to the “display” program:

magick logo: gif:- | magick display gif:-

The explicit “gif:” format designation a second time is optional in the previous example. The GIF image format has a unique signature within the image, so ImageMagick's rendering command can easily recognize the format as GIF. The magick program also takes STDIN as input as follows:

magick rose: gif:- | magick - -resize "200%" bigrose.jpg'

Other pipes can be accessed through their file descriptors. File descriptors 0, 1, and 2 are reserved for the standard streams STDIN, STDOUT, and STDERR, respectively, but the pipe associated with file descriptor number N>2 can be accessed using the alias fd:N. (The fd:0 and fd:1 aliases can be used for STDIN and STDOUT). The following example shows how to add image data piped from files with descriptor 3 and 4 and pipe the result to file descriptor number 5.

magick fd:3 fd:4 -append fd:5

Optionally, explicit image formats can be specified, as mentioned earlier, as shown below.

magick gif:fd:3 jpg:fd:4 -append tif:fd:5

Frame selection

Some image formats contain more than one image frame. Maybe you only want the first image, or the last one, or some number of intermediate images. You can specify which image frames to read by appending a range of frames enclosed in parentheses to the image file name. Here our image (an animated GIF) contains more than one frame, but we only need the first one:

magick 'images.gif[0]' image.png

Note: Linux shells usually interpret parentheses, which is why we enclosed the filename in quotation marks above. The Windows shell doesn't interpret parentheses, but it's good to use quotes. However, in most cases, the roles of single and double quotes are reversed with respect to Linux and Windows, so Windows users should generally use double quotes where we display single quotes, and vice versa.

You can read more than one image from a sequence with a range of frames. For example, you can extract the first four frames of an image sequence:

magick 'images.gif[0-3]' images.mng

The default is to step one frame at a time, so frames 0, 1, 2, and 3 are returned. Set the step to 2 with -define frames:step=2, and we'll get frames 0 and 2 instead.

Finally, you can read more than one image from a sequence, out of order. The following command gets the fourth image in the sequence, then the third, and then the fifth:

magick 'images.gif[3,2,4]' images.mng

Note that the last two commands write a single image. The final file in this case, when the image type is MNG, is a multi-frame file because the MNG format supports multiple frames. If the output format was JPG, which only supports single image files, the output would consist of multiple files with individual frames in each. More on this below, in the section on Output file name.

Image area selection

Raw images are a sequence of color intensities with no additional meta-information such as width, height, or image caption. In raw image formats, you must specify the width and height of the image, but you can also specify the area of the image to read. In our example, the image is in raw 8-bit RGB format and is 6000 pixels wide by 4000 pixels high. However, we only want a 600 x 400 area near the center of the image:

magick -size 6000x4000 -depth 8 'rgb:image[600x400+1900+2900]' image.jpg

You can get the same results with the -extract option (see also How to extract a region of an image (cropping a picture)):

LINK

magick -size 6000x4000 -depth 8 -extract 600x400+1900+2900 rgb:image image.jpg

Image resizing while reading

Sometimes it's convenient to resize an image as you read it. Let's say you have hundreds of large JPEG images that you want to convert to a sequence of PNG thumbnails:

magick '*.jpg' -resize 120x120 thumbnail%03d.png

The previous command first reads all the images, which are subsequently scaled. It's faster and less resource intensive to resize each image while it's being read:

magick '*.jpg[120x120]' thumbnail%03d.png

Image cropping while reading

Sometimes it's convenient to crop an image as you read them. Let's say you have hundreds of large JPEG images that you want to convert to a sequence of PNG thumbnails:

magick '*.jpg' -crop 120x120+10+5 thumbnail%03d.png

The previous command first reads all the images, which are subsequently cropped. It's faster and less resource-intensive to crop each image as it's read:

magick '*.jpg[120x120+10+5]' thumbnail%03d.png

Links to a file with filenames

There are two methods for using a filename to refer to other image filenames. The first one is with '@', which reads space-separated image filenames from the specified file. Let's assume the file myimages.txt consists of a list of filenames, like so:

frame001.jpg
frame002.jpg
frame003.jpg

Then the following command:

magick @myimages.txt mymovie.gif

reads the image files frame001.jpg, frame002.jpg and frame003.jpg and converts them into a sequence of GIF images.

If the image path contains one or more spaces, enclose the path in quotation marks:

'my title.jpg'

Note: Please note that linking to a file using the @ symbol can be used with other options, not just as a file with image names. In fact, you can put the value of any options in a file and load a line from the file using the @ symbol. For example, with @ you can specify the path to the font with the -font option, or a text file with the -annotate option.

LINK

LINK

Another method of referring to other image files is by embedding a formatting character in the filename with a scene range. Consider the filename image-%d.jpg[1-5]. The command

magick image-%d.jpg[1-5]

causes ImageMagick to try to read images with these filenames:

image-1.jpg
image-2.jpg
image-3.jpg
image-4.jpg
image-5.jpg

Stream Buffering

By default, the input stream is buffered. To ensure that source file or terminal information is read as soon as it is available, set the buffer size to 0:

magick logo: gif:- | magick display -define stream:buffer-size=0 gif:-

Command line options

You can control the behavior of the ImageMagick utilities with these command line options. The behavior of an option falls into one of the following categories:

  • Image Setting
  • Image Operator
  • Image Channel Operator
  • Image Sequence Operator
  • Image Geometry
  • Image Stack

Image Setting

An image setting persists as it appears on the command-line and may affect subsequent processing such as reading an image, an image operator, or when writing an image as appropriate. An image setting stays in effect until it is reset or the command-line terminates. The image settings include:

In this example, -channel applies to each of the images, since, as we mentioned, settings persist:

magick -channel RGB wand.png wizard.png images.png

Image Operator

An image operator differs from a setting in that it affects the image immediately as it appears on the command-line. An operator is any command-line option not listed as a image setting or image sequence operator. Unlike an image setting, which persists until the command-line terminates, an operator is applied to the current image set and forgotten. The image operators include:

In this example, -negate negates the wand.png image but not the wizard.png image:

magick wand.png -negate wizard.png images.png 

Note that an image operator will be applied to each images in an image sequence. For example, if you use -resize option to resize a GIF image, each frames will be resized to the given size. However, some frames may be smaller than the whole image and resizing all the frames into the same size may result in an unexpected output. In such a case, -coalesce should be used to prepare those frames.

Image Channel Operator

They work directly with image channels:

Image Sequence Operator

An image sequence operator differs from a setting in that it affects an image sequence immediately as it appears on the command-line. Choose from these image sequence operators:

In this example, -append appends three images into one:

magick mikayla.png picnic.png beach.png -append vacation.png

Image stack

In school, your teacher probably permitted you to work on problems on a scrap of paper and then copy the results to your test paper. An image stack is similar. It permits you to work on an image or image sequence in isolation and subsequently introduce the results back into the command-line. The image stack is delineated with parenthesis. Image operators only affect images in the current stack. For example, we can limit the image rotation to just the wizard.gif image like this:

magick wand.gif \( wizard.gif -rotate 30 \) +append images.gif

Notice again that the parentheses are escaped by preceding them with backslashes. This is required under Linux, where parentheses are special shell characters. The backslash tells the shell not to interpret these characters, but to pass them directly to the command being executed. Do not escape the parentheses under Windows. Each parenthesis (or escaped parenthesis) must have spaces on either side, as in the example shown above.

In addition to the image operators already discussed, the following image operators are most useful when processing images in an image stack:

The arguments to these operators are indexes into the image sequence by number, starting with zero, for the first image, and so on. However if you give a negative index, the images are indexed from the end (last image added). That is, an index of -1 is the last image in the current image sequence, -2 gives the second-to-last, and so on.

Image Geometry

Image geometry belongs to the previous section – Command line options – but it is a very voluminous and important aspect of the topic, so it is separated into a separate paragraph. Just remember that Image Geometry is a kind of command line option.

Many options take what is called Geometry as a value. ImageMagick's Geometry refers to the numbers that indicate the size of the image, as well as the coordinates of its location. On the one hand, Geometry is quite simple, since it can include size and offset, or only one of these quantities. But on the other hand, ImageMagick is very flexible in the way it defines the Geometry, so using the full syntax for specifying the size and shift, you can accurately convey your intentions to the program. In addition, the geometry can be interpreted a little differently by the options to which it is passed.

Many command-line options take a geometry argument to specify things like the desired image width and height, and other dimensional values. Because users need so many options for the resulting image sizes, dimensions, and positions (and because ImageMagick wants to provide them), the geometry argument can take many forms. We will describe many of them in this section.

Be aware that some of the options parse their arguments slightly differently. Image options and settings that take the form of a geometry argument include the following:

The geometry argument can take any of the forms listed in the table below. They will be described in more detail in the subsections following the table. The usual form is SIZE[OFFSET], which means that size is required and offset is optional. Sometimes (for some options) [SIZE]OFFSET is possible. Under no circumstances are spaces allowed in the geometry argument.

Let's consider how the first, obligatory part of the Geometry, the SIZE, can be set.

Size General description (actual behavior may vary depending on parameters and settings)
SCALE% The height and width are scaled by the specified percentage.
SCALE-x%xSCALE-y% The height and width are individually scaled by the specified percentage. (Only one % is required, but two can be specified if desired.)
WIDTH The specified width is applied, the height is automatically selected to maintain the aspect ratio.
XHEIGHT The specified height is applied, the width is automatically selected to maintain the aspect ratio.
WIDTHxHEIGHT Sets the maximum height and width values, keeping the aspect ratio.
WIDTHxHEIGHT^ Sets the minimum width and height values, keeping the aspect ratio.
WIDTHxHEIGHT! Width and height are specified categorically, the original aspect ratio is ignored.
WIDTHxHEIGHT> Reduces an image larger than the corresponding width and/or height arguments.
WIDTHxHEIGHT< Enlarges the image at a size smaller than the corresponding width and/or height arguments.
AREA@ Resize the image to have the specified area in pixels. The aspect ratio is preserved.
x:y Here x and y represent the aspect ratio (for example, 3:2 = 1.5).
x:y^ Delete rows or columns to achieve the specified aspect ratio.
x:y# Add rows or columns to achieve the specified aspect ratio.

In all previous forms of Geometry notation, Offset is not specified. An Offset can be added to any of the above entries:

{SIZE}{OFFSET}

The Offset is two signed numbers:

SIZE{+-}x{+-}y

Horizontal and vertical x and y offsets are specified in pixels. Signs are needed for both digits.

If no offset is specified, it defaults to +0+0. But in my tests, not specifying an offset led to unexpected results. That is, if you, for example, use the -gravity option, and do not want to shift the image relative to the new center of gravity, then specify +0+0 as the offset. See also The -gravity option defines the origin for the Offset.

Remember that by default the origin (coordinates 0; 0) is the upper left corner.

Offsets are affected by the -gravity parameter. Offsets are not affected by % or other size operators. Note that the positive X and Y offsets are inward toward the center of the image for all gravity settings except “Center”. For “East” +X it is to the left. For “South” +Y it's up. For “SouthEast” +X on the left and +Y on the top. “Center” uses the usual X and Y direction convention (+X for right and +Y for down).

Basic width and height settings; operators %, ^ and !

Here, just below, are some simple examples of geometry showing how it can be used as an argument to the -resize option. We will be using the internal image logo: for our input image. This image is 640 pixels wide and 480 pixels high, making it 640×480. When we size an image, the width (horizontal size) always comes before the height (vertical size). This will be true when we talk about coordinates or offsets in an image, which will always be an x value followed by a y. Just think of school lessons in algebra and the xy plane. (Well, almost: our Y axis will always point down!)

magick logo: -resize '200%' bigWiz.png
magick logo: -resize '200x50%' longShortWiz.png
magick logo: -resize '100x200' notThinWiz.png
magick logo: -resize '100x200^' biggerNotThinWiz.png
magick logo: -resize '100x200!' dochThinWiz.png

The first of the four commands is simple – it stretches both the width and height of the input image by 200% in each direction; it doubles it all. The second command sets different percentages for each direction, stretching the width to 200% and shrinking the height to 50%. The resulting image (in this example) is 1280×240. Note that the percent symbol does not need to be repeated; the following entries are equivalent: 200×50%, 200%x50, 200%x50%.

By default, the width and height specified in the geometry argument are the maximum values unless a percentage value is specified. That is, the image expands or shrinks to fit the specified width and height while maintaining the aspect ratio (ratio of height to width) of the image. For example, the third command above is “trying” to set the dimensions to 100×200. Imagine that the original image (640×480) is progressively compressed, keeping the aspect ratio constant, until it fits into a 100×200 rectangle. Since the length of the image is greater than the height, it will fit if its width is reduced to 100 pixels. To keep the aspect ratio, the height should be (480/640)x100px=75px, so the final dimensions will be 100×75.

Note that the previous example will achieve at least one of the specified dimensions (in this case, the width is 100px). The resulting image is close to the original. You can do the exact opposite of this by calling the ^ operator, as in the fourth example above. In this case, when 100×200^ is given as an argument, at least one of the dimensions will be reached again, here the geometry argument gives the minimum values. In our example, the height will become 200 and the width will be scaled to keep the aspect ratio and becomes (640/480) × 200 pixels = 267 pixels. With the ^ operator, one of these sizes will match the requested size, but the image will likely go beyond the requested sizes to maintain the aspect ratio.

We can see that ImageMagick preserves the aspect ratio of images very well to prevent distortion of your favorite photos and images. But you may actually want the dimensions to be 100×200, thereby stretching the image. In this case, just tell ImageMagick that you really mean it by adding an exclamation point (!) to the geometry. This will cause the image to be exactly the size you specify. So, for example, if you specify 100×200! the dimensions will become exactly 100×200 (it turns out a small, vertically elongated wizard).

Restriction of width, height and area; operators >, < and @

Here are some more examples:

magick logo: -resize '100' wiz1.png
magick logo: -resize 'x200' wiz2.png
magick logo: -resize '100x200>' wiz3.png
magick logo: -resize '100x200<' wiz4.png

If only one size is specified, it is taken as the width. When only the width is specified, as in the first example above, the width is taken as given and the height is chosen to maintain the aspect ratio of the input image. Similarly, if only the height is specified, as in the second example above, the height is taken and the width is adjusted to maintain the aspect ratio.

Use > to shrink an image only if its dimensions are larger than the corresponding width and/or height arguments. Use < to enlarge an image only if its dimensions are smaller than the corresponding width and/or height arguments. In any case, if changes are made, the result will be the same as if the > or < operator was not present. So in the third example above, we have specified 100×200> and the original image size is 640×480, so the image size is reduced as if we specified 100×200. However, in the fourth example above, its size will not change.

Finally, use @ to specify the maximum area of the image in pixels, again trying to keep the aspect ratio. (Pixels only take integer values, so some approximation is always used.) The following example requests an area of 10,000 pixels. The resulting file is 115×86, which is 9890 pixels.

magick logo: -resize '10000@' wiz10000.png

Note: In all the examples above and below, the geometry arguments are enclosed in quotation marks. In many cases this is optional, but not always. We must quote geometry specifications when using < or > to prevent the shell from interpreting these characters as a file redirect. On Windows systems, the ^ character must be enclosed in quotation marks, otherwise it is ignored. To be on the safe side, you should probably keep the habit of quoting all geometry arguments, as we did here.

Offsets in Geometry

Here are some examples to illustrate the use of offsets in geometry arguments. One typical use of offsets is in conjunction with the -region option. This option allows many other options to modify the pixels within a specified rectangular subregion of an image. As such, it needs to be given the width and height of that region, and also an offset into the image, which is a pair of coordinates that indicate the location of the region within the larger image. Below, in the first example, we specify a region of size 100×200 to be located at the xy–coordinates x=10, y=20. Let's use the usual algebraic notation (x,y)=(10,20), for convenience.

magick logo: -region '100x200+10+20' -negate wizNeg1.png
magick logo: -region '100x200-10+20' -negate wizNeg2.png
magick logo: -gravity center -region '100x200-10+20' -negate wizNeg3.png

Note that offsets always require +/ signs. The offset is not actually a true location within the image; its coordinates must be added to some other location. Let's refer to that as the current location. In the first two examples above, though, that location is the upper-left hand corner of the image, which has coordinates (0,0). (That is the default situation when there are no other directives given to change it.) The first example above puts the 100×200 rectangle's own upper-left corner at (10,20).

A negative offset can make sense in many cases. In the second example above, the offset is (-10,20), specified by -10+20. In that case, only the portion of the (virtual) rectangle obtained that lies within the image can be negated; here it is equivalent to specifying the geometry as 90×200+0+20.

In the third example above, the -gravity setting precedes the others and sets the current location within the image at the very center of the image. In this case that is at pixel (320,240), since the size of the image is 640×480. This means that the offsets apply to that location, which thereby gets moved, in this case, to (320-10,240+20)=(310,260). But the 100×200 region itself is affected by the -gravity setting, so instead of affecting its upper-left corner, the region's own center (at (+50,+100) within it) is determined. Therefore the center of the 100×200 rectangle is moved to (310,260). The negated rectangle's upper-left corner is now at (310-50,260-100)=(260,160).

The -gravity option defines the origin for the Offset

As already mentioned, by default for OFFSET, the origin is the upper left corner of the image. With the -gravity TYPE option, you can choose a different origin.

The -gravity option sets the current gravity suggestion for various other settings and options.

Possible TYPES:

  • None
  • Center
  • East
  • Forget
  • NorthEast
  • North
  • NorthWest
  • SouthEast
  • South
  • SouthWest
  • West

For a complete list of -gravity options available in your ImageMagick installation use:

magick -list gravity

The selected direction indicates where to place the text or parts of the image. For example, the “Center” gravity forces the text to be centered in the image. By default, image gravity is undefined. See the -draw option for more information on drawing primitives. Of the -draw primitives, the -gravity parameter only affects the text primitive.

The -gravity option is also used in conjunction with the -geometry option and other options or options that take geometry as an argument, such as the -crop option.

If the -gravity parameter occurs before another parameter or option that has a geometry argument that specifies an offset, the offset is usually applied to the point in the image suggested by the -gravity argument. So, for example, in the following command, the image.png file is 200×100. The offset specified by the argument to -region is (-40,+20). The -gravity argument is “Center”, which points to the middle of the image at (100,50). An offset (-40.20) is applied to that point, which gives (100-40.50+20)=(60.70), so the specified 10×10 area is at that point. (Also, -gravity affects the region itself, centered at pixel coordinate (60,70). (See the geometry argument above for more on the geometry argument.)

magick image.png -gravity Center -region 10x10-40+20 -negate output.png

When used as an option for -composite, -gravity specifies the direction in which the image gravitates within the composite.

Use +gravity to reset gravity to default.

Output file name

ImageMagick extends the concept of an output file name, in addition to specifying a relative or absolute path to the file where the image should be saved, apply:

  1. explicit image format
  2. write to standard output
  3. specifying a file name pattern

Each of these extensions is explained in the next few paragraphs.

If you do not want to write the final image to a file, then use the -exit option instead of the output file name.

Explicit image format

Images can be stored in a variety of graphic formats, including the more well-known JPEG, PNG, TIFF, and others. ImageMagick needs to know the desired image format before it can be written. ImageMagick uses the filename extension to determine the format. For example, image.jpg tells ImageMagick to write the image as a JPEG. In some cases, the filename does not determine the format of the image. In these cases, the image is written in the format it was originally read in, unless an explicit image format is specified. For example, let's say we want to write our image to a file called image in raw red, green, and blue intensity format:

magick image.jpg rgb:image

Standard output

Linux allows you to pipe the output of one command to another. ImageMagick allows you to pass the output image to another command by specifying - (hyphen) as the file name. In this example, we are piping the output of “magick” to the “display” program:

magick logo: gif:- | magick display gif:-

Here the explicit format is optional. The GIF image format has a signature that uniquely identifies it, so ImageMagick can easily recognize the format as GIF.

Specifying a file name pattern

The program supports built-in characters to indicate formatting. Suppose our output file name is image-%d.jpg and our image list includes 3 images. You can expect these image files to be written with the names:

image-0.jpg
image-1.jpg
image-2.jpg

You can also use image properties to form a file name string. For example, the command

magick rose: -set filename:area '%wx%h' 'rose-%[filename:area].png'

writes an image with this filename:

rose-70x46.png

A list of possible attributes and their conventions in the form of escaped characters can be found at the link: https://imagemagick.org/script/escape.php

Some “properties” must be defined in a special way in order to be used. For example, only “properties” prefixed with “filename:” can be used to change the output filename of an image. That is, in the example shown above, the “filename:” prefix is required, and any other name can be used instead of the “area” variable.

One more example:

mkdir preview
magick *.jpg[100x] -set filename:currentfile '%f-%wx%h' 'preview/%[filename:currentfile].jpg'

Finally, to convert multiple JPEG images into single PDF pages, use:

magick *.jpg +adjoin page-%d.pdf

Use “-define filename:literal=true” to bypass the interpretation of built-in format characters and instead use the filename literally, i.e. the name of the saved files in this case will contain a percent sign and a letter.

Stream buffering

By default, the output stream is buffered. To display information in the target file or terminal immediately after writing, set the buffer size to 0:

magick -define stream:buffer-size=0 logo: gif:- | magick display gif:-

The order of options matters in ImageMagick

In addition to the fact that options can affect the entire command or only for a specific image, the order in which options are applied must also be considered, since a “magick” command can include many stages of processing one or more images.

Consider the following command:

magick IMAGE.jpg -rotate 30 -background red test8.jpg

As planned, the image should be rotated by 30 degrees, and the empty corners that appear should be filled with red. As a result of executing the command, the image will indeed be rotated, but the corners will remain white.

To fix the error, you must specify the -background option first. The following command will work exactly as intended:

magick IMAGE.jpg -background red -rotate 30 test8.jpg

magick options are divided into different groups (image settings, image operators, image channel operators, image sequence operator, image geometry, image stack) and affect either all images or images after which the option is specified. In this case, the reason that the -background option didn't work in the first command seems to be that the options are applied sequentially:

  1. First, the -rotate image operator is applied, and the empty corners that appear are filled with the default background (white).
  2. Then a new background setting is set, which, as a result of the command, no longer affects anything.

In the second command, the sequence of action is as follows:

  1. The -background option sets the new background color (red).
  2. The image operator -rotate rotates the image, and the empty corners that appear are filled with the background color, in this case, the background color is set to red.

While this is counter-intuitive, since in most Linux utilities the order of the options does not matter, in ImageMagick (magick) the order of the options does matter!

How to specify color in ImageMagick

A number of ImageMagick options and methods take a color as an argument. The color can then be given as a color name (there is a limited but large set of these; see below) or it can be given as a set of numbers (in decimal or hexadecimal), each corresponding to a channel in an RGB or RGBA color model. HSL, HSLA, HSB, HSBA, CMYK, or CMYKA color models may also be specified. These topics are briefly described in the sections below.

Use the Color Converter to supply any valid ImageMagick color specification as described below to see a color swatch of that color and to convert to all the other color models.

To display the names of the colors, run the command (also these names and the colors themselves are given in the table below):

magick -list color

Example Usage

Each of the following commands produces the same lime border around the image. (Use "double quotes" for Windows.)

magick -bordercolor lime -border 10 image.jpg image.png
magick -bordercolor '#0f0' -border 10 image.jpg image.png
magick -bordercolor '#00ff00' -border 10 image.jpg image.png
magick -bordercolor 'rgb(0,255,0)' -border 10 image.jpg image.png
magick -bordercolor 'rgb(0,100%,0)' -border 10 image.jpg image.png

The list of recognized color names (for example, aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, yellow, and others) is shown in a table further below.

Color Model Specification

The sRGB, CMYK, HSL and HSB color models are used in numerical color specifications. These examples all specify the same red sRGB color:

#f00                      #rgb
#ff0000                   #rrggbb
#ff0000ff                 #rrggbbaa
#ffff00000000             #rrrrggggbbbb
#ffff00000000ffff         #rrrrggggbbbbaaaa
rgb(255, 0, 0)            an integer in the range 0—255 for each component
rgb(100.0%, 0.0%, 0.0%)   a float in the range 0—100% for each component

The format of an sRGB value in hexadecimal notation is a '#' immediately followed by either three, six, or twelve hexadecimal characters. The three-digit sRGB notation (#rgb) is converted into six-digit form (#rrggbb) by replicating digits, not by adding zeros. For example, #fb0 expands to #ffbb00. This ensures that white (#ffffff) can be specified with the short notation (#fff) and removes any dependencies on the color depth of the image. Use the hexadecimal notation whenever performance is an issue. ImageMagick does not need to load the expansive color table to interpret a hexadecimal color, e.g., #000000, but it does if black is used instead.

The format of an sRGB value in the functional notation is 'rgb(r,g,b)', where r, g, and b are either three integer or float values in the range 0—255 or three integer or float percentage values in the range 0—100%. The value 255 corresponds to 100%, and to #F or #FF in the hexadecimal notation: rgb(255, 255, 255) = rgb(100%, 100%, 100%) = #FFF = #FFFFFF. Note, as of ImageMagick 7.0.10-53, the commas are no longer necessary and the slash can proceed the alpha value, e.g. rgb(255 128 0 / 50%).

White space characters are allowed around the numerical values, at least if the entire color argument is enclosed in quotes ('single quotes' for Linux-like systems, "double quotes" for Windows).

The sRGB color model is extended in this specification to include alpha to allow specification of the transparency of a color. These examples all specify the same color:

rgb(255, 0, 0)                 range 0 - 255
rgba(255, 0, 0, 1.0)           the same, with an explicit alpha value
rgb(100%, 0%, 0%)              range 0.0% - 100.0%
rgba(100%, 0%, 0%, 1.0)        the same, with an explicit alpha value

The format of an RGBA value in the functional notation is 'rgba(r,g,b,a)', where r, g, and b are as described above for the RGB functional notation, and where the alpha value a ranges from 0.0 (fully transparent) to 1.0 (fully opaque).

There is also a color called 'none' that is fully transparent. This color is shorthand for rgba(0, 0, 0, 0.0).

Non-linear gray values are conveniently defined with a name, single intensity value or an intensity value and an alpha value:

gray50            near mid gray
gray(127)         near mid gray
gray(50%)         mid gray
graya(50%, 0.5)   semi-transparent mid gray

For linear gray values add -colorspace RGB -colorspace Gray or -colorspace LinearGray when creating gray colors. The latter is new as of Imagemagick 6.9.9-29 and 7.0.7-17.

The ImageMagick color model also supports hue-saturation-lightness (HSL) and hue-saturation-brightness (HSB) colors as a complement to numerical sRGB colors. HSL colors are encoding as a triple (hue, saturation, lightness). Likewise HSB colors are encoding as a triple (hue, saturation, brightness). HSL or HSB triples are either direct values (hue 0—360, saturation 0—255, lightness or brightness 0—255) or with S,L,B as percentage values relative to these ranges.

The HSB color system is geometrically represented as a cone with its apex pointing downward. Hue is measured around the perimeter. Saturation is measured from the axis outward. Brightness is measured from the apex upward.

The HSL color system is geometrically represented as a stacked double cone with one apex pointing downward and the other pointing upward. The widest ends of both cones are stacked together one on top of the other. Hue is measured around the perimeter. Saturation is measured from the axis outward. Lightness is measured from the bottom apex upward.

See http://en.wikipedia.org/wiki/HSL_and_HSV for more details on HSL and HSB color systems.

Hue is represented as an angle of the color around the circular perimeter of the cone(s) (i.e. the rainbow represented in a circle). Hue values are integers or floats in the range 0—360. By definition red=0=360, and the other colors are spread around the circle, so green=120, blue=240, etc. As an angle, it implicitly wraps around such that -120=240 and 480=120, for instance. (Students of trigonometry would say that "coterminal angles are equivalent" here; an angle θ can be standardized by computing the equivalent angle, θ mod 360.)

Saturation is measure outward from the central axis of the cone(s) toward the perimeter of the cone(s). Saturation may be expressed as an integer or float in the range 0—255 or as an integer or float percentage in the range 0—100. Saturation may be thought of as the absence of any "white" mixed with the base color. Thus 255 or 100% is full saturation and corresponds to a point on the outside surface of the cone (HSB) or double cone (HSL). It will be the most "colorful" region. 0 or 0% is no saturation which results in some shade of gray. It occurs along the central axis of the cone or double cone with black at the bottom apex and white at the top.

Brightness and Lightness also may be represented as integers or floats in the range 0—255 or as integer or float percentages in the range 0—100%. Brightness and Lightness are measured from the bottom apex upward to the top of the cone or double cone along the cone(s) central axis. 0 or 0% corresponds to the bottom apex and 255 or 100% corresponds to the top center of the cone for Brightness and to the top apex of the double cone for Lightness.

The HSB color system is a little easier to understand than the HSL color system. In the HSB color system, black is at the bottom apex and white is at the top center of the cone on the central axis. The most colorful or saturated colors will then be at the outer edge of the top of the cone at the widest part. Thus at Saturation=100% and Brightness=100%

hsb(0,   100%,  100%)    or    hsb(0,   255,   255)       full red
hsb(120, 100%,  100%)    or    hsb(120, 255,   255)       full green
hsb(120, 100%,  75%)     or    hsb(120, 255,   191.25)    medium green
hsb(120, 100%,  50%)     or    hsb(120, 255,   127.5)     dark green
hsb(120, 100%,  25%)     or    hsb(120, 255,   63.75)     very dark green
hsb(120, 50%,   50%)     or    hsb(120, 127.5, 127.5)     pastel green

In the HSL color system, black is at the bottom apex and white is at the top apex. However, saturation is largest at the middle of the double cone on its outer perimeter and thus at a lightness value of 50%. The most colorful or saturated colors will then be at the outer edge of the double cone at its widest part. Thus at Saturation=100% and Brightness=50%

hsl(0,   100%,  50%)     or    hsl(0,   255,   127.5)     full red
hsl(120, 100%,  100%)    or    hsl(120, 255,   255)       white
hsl(120, 100%,  75%)     or    hsl(120, 255,   191.25)    pastel green
hsl(120, 100%,  50%)     or    hsl(120, 255,   127.5)     full green
hsl(120, 100%,  25%)     or    hsl(120, 255,   63.75)     dark green
hsl(120, 50%,   50%)     or    hsl(120, 127.5, 127.5)     medium green

One advantage of HSB or HSL over RGB is that it can be more intuitive: you can guess at the colors you want, and then tweak. It is also easier to create sets of matching colors (by keeping the hue the same and varying the brightness or lightness and saturation, for example).

Just as the 'rgb()' functional notation has the 'rgba()' alpha counterpart, the 'hsl()' and 'hsb()' functional notations have their 'hsla()' 'hsba()' alpha counterparts. These examples specify the same color:

hsb(120, 100%,  100%)              full green in hsb
hsba(120, 100%,  100%,  1.0)       the same, with an alpha value of 1.0
hsb(120, 255,  255)                full green in hsb
hsba(120, 255,  255,  1.0)         the same, with an alpha value of 1.0

hsl(120, 100%,  50%)               full green in hsl
hsla(120, 100%,  50%,  1.0)        the same, with an alpha value of 1.0
hsl(120, 255,  127.5)              full green in hsl
hsla(120, 255,  127.5,  1.0)       the same, with an alpha value of 1.0

ImageMagick also supports wide-gamut color such as Lab, LCH, and Display-P3.

List of Color Names

The table below provides a list of named colors recognized by ImageMagick:

Имя Цвет RGB Hex
snow snow rgb(255, 250, 250) #FFFAFA
snow1 snow1 rgb(255, 250, 250) #FFFAFA
snow2 snow2 rgb(238, 233, 233) #EEE9E9
RosyBrown1 RosyBrown1 rgb(255, 193, 193) #FFC1C1
RosyBrown2 RosyBrown2 rgb(238, 180, 180) #EEB4B4
snow3 snow3 rgb(205, 201, 201) #CDC9C9
LightCoral LightCoral rgb(240, 128, 128) #F08080
IndianRed1 IndianRed1 rgb(255, 106, 106) #FF6A6A
RosyBrown3 RosyBrown3 rgb(205, 155, 155) #CD9B9B
IndianRed2 IndianRed2 rgb(238, 99, 99) #EE6363
RosyBrown RosyBrown rgb(188, 143, 143) #BC8F8F
brown1 brown1 rgb(255, 64, 64) #FF4040
firebrick1 firebrick1 rgb(255, 48, 48) #FF3030
brown2 brown2 rgb(238, 59, 59) #EE3B3B
IndianRed IndianRed rgb(205, 92, 92) #CD5C5C
IndianRed3 IndianRed3 rgb(205, 85, 85) #CD5555
firebrick2 firebrick2 rgb(238, 44, 44) #EE2C2C
snow4 snow4 rgb(139, 137, 137) #8B8989
brown3 brown3 rgb(205, 51, 51) #CD3333
red red rgb(255, 0, 0) #FF0000
red1 red1 rgb(255, 0, 0) #FF0000
RosyBrown4 RosyBrown4 rgb(139, 105, 105) #8B6969
firebrick3 firebrick3 rgb(205, 38, 38) #CD2626
red2 red2 rgb(238, 0, 0) #EE0000
firebrick firebrick rgb(178, 34, 34) #B22222
brown brown rgb(165, 42, 42) #A52A2A
red3 red3 rgb(205, 0, 0) #CD0000
IndianRed4 IndianRed4 rgb(139, 58, 58) #8B3A3A
brown4 brown4 rgb(139, 35, 35) #8B2323
firebrick4 firebrick4 rgb(139, 26, 26) #8B1A1A
DarkRed DarkRed rgb(139, 0, 0) #8B0000
red4 red4 rgb(139, 0, 0) #8B0000
maroon maroon (SVG compliance) rgb(128, 0, 0) #800000
LightPink1 LightPink1 rgb(255, 174, 185) #FFAEB9
LightPink3 LightPink3 rgb(205, 140, 149) #CD8C95
LightPink4 LightPink4 rgb(139, 95, 101) #8B5F65
LightPink2 LightPink2 rgb(238, 162, 173) #EEA2AD
LightPink LightPink rgb(255, 182, 193) #FFB6C1
pink pink rgb(255, 192, 203) #FFC0CB
crimson crimson rgb(220, 20, 60) #DC143C
pink1 pink1 rgb(255, 181, 197) #FFB5C5
pink2 pink2 rgb(238, 169, 184) #EEA9B8
pink3 pink3 rgb(205, 145, 158) #CD919E
pink4 pink4 rgb(139, 99, 108) #8B636C
PaleVioletRed4 PaleVioletRed4 rgb(139, 71, 93) #8B475D
PaleVioletRed PaleVioletRed rgb(219, 112, 147) #DB7093
PaleVioletRed2 PaleVioletRed2 rgb(238, 121, 159) #EE799F
PaleVioletRed1 PaleVioletRed1 rgb(255, 130, 171) #FF82AB
PaleVioletRed3 PaleVioletRed3 rgb(205, 104, 137) #CD6889
LavenderBlush LavenderBlush rgb(255, 240, 245) #FFF0F5
LavenderBlush1 LavenderBlush1 rgb(255, 240, 245) #FFF0F5
LavenderBlush3 LavenderBlush3 rgb(205, 193, 197) #CDC1C5
LavenderBlush2 LavenderBlush2 rgb(238, 224, 229) #EEE0E5
LavenderBlush4 LavenderBlush4 rgb(139, 131, 134) #8B8386
maroon maroon (X11 compliance) rgb(176, 48, 96) #B03060
HotPink3 HotPink3 rgb(205, 96, 144) #CD6090
VioletRed3 VioletRed3 rgb(205, 50, 120) #CD3278
VioletRed1 VioletRed1 rgb(255, 62, 150) #FF3E96
VioletRed2 VioletRed2 rgb(238, 58, 140) #EE3A8C
VioletRed4 VioletRed4 rgb(139, 34, 82) #8B2252
HotPink2 HotPink2 rgb(238, 106, 167) #EE6AA7
HotPink1 HotPink1 rgb(255, 110, 180) #FF6EB4
HotPink4 HotPink4 rgb(139, 58, 98) #8B3A62
HotPink HotPink rgb(255, 105, 180) #FF69B4
DeepPink DeepPink rgb(255, 20, 147) #FF1493
DeepPink1 DeepPink1 rgb(255, 20, 147) #FF1493
DeepPink2 DeepPink2 rgb(238, 18, 137) #EE1289
DeepPink3 DeepPink3 rgb(205, 16, 118) #CD1076
DeepPink4 DeepPink4 rgb(139, 10, 80) #8B0A50
maroon1 maroon1 rgb(255, 52, 179) #FF34B3
maroon2 maroon2 rgb(238, 48, 167) #EE30A7
maroon3 maroon3 rgb(205, 41, 144) #CD2990
maroon4 maroon4 rgb(139, 28, 98) #8B1C62
MediumVioletRed MediumVioletRed rgb(199, 21, 133) #C71585
VioletRed VioletRed rgb(208, 32, 144) #D02090
orchid2 orchid2 rgb(238, 122, 233) #EE7AE9
orchid orchid rgb(218, 112, 214) #DA70D6
orchid1 orchid1 rgb(255, 131, 250) #FF83FA
orchid3 orchid3 rgb(205, 105, 201) #CD69C9
orchid4 orchid4 rgb(139, 71, 137) #8B4789
thistle1 thistle1 rgb(255, 225, 255) #FFE1FF
thistle2 thistle2 rgb(238, 210, 238) #EED2EE
plum1 plum1 rgb(255, 187, 255) #FFBBFF
plum2 plum2 rgb(238, 174, 238) #EEAEEE
thistle thistle rgb(216, 191, 216) #D8BFD8
thistle3 thistle3 rgb(205, 181, 205) #CDB5CD
plum plum rgb(221, 160, 221) #DDA0DD
violet violet rgb(238, 130, 238) #EE82EE
plum3 plum3 rgb(205, 150, 205) #CD96CD
thistle4 thistle4 rgb(139, 123, 139) #8B7B8B
fuchsia fuchsia rgb(255, 0, 255) #FF00FF
magenta magenta rgb(255, 0, 255) #FF00FF
magenta1 magenta1 rgb(255, 0, 255) #FF00FF
plum4 plum4 rgb(139, 102, 139) #8B668B
magenta2 magenta2 rgb(238, 0, 238) #EE00EE
magenta3 magenta3 rgb(205, 0, 205) #CD00CD
DarkMagenta DarkMagenta rgb(139, 0, 139) #8B008B
magenta4 magenta4 rgb(139, 0, 139) #8B008B
purple purple (SVG compliance) rgb(128, 0, 128) #800080
MediumOrchid MediumOrchid rgb(186, 85, 211) #BA55D3
MediumOrchid1 MediumOrchid1 rgb(224, 102, 255) #E066FF
MediumOrchid2 MediumOrchid2 rgb(209, 95, 238) #D15FEE
MediumOrchid3 MediumOrchid3 rgb(180, 82, 205) #B452CD
MediumOrchid4 MediumOrchid4 rgb(122, 55, 139) #7A378B
DarkViolet DarkViolet rgb(148, 0, 211) #9400D3
DarkOrchid DarkOrchid rgb(153, 50, 204) #9932CC
DarkOrchid1 DarkOrchid1 rgb(191, 62, 255) #BF3EFF
DarkOrchid3 DarkOrchid3 rgb(154, 50, 205) #9A32CD
DarkOrchid2 DarkOrchid2 rgb(178, 58, 238) #B23AEE
DarkOrchid4 DarkOrchid4 rgb(104, 34, 139) #68228B
purple purple (X11 compliance) rgb(160, 32, 240) #A020F0
indigo indigo rgb( 75, 0, 130) #4B0082
BlueViolet BlueViolet rgb(138, 43, 226) #8A2BE2
purple2 purple2 rgb(145, 44, 238) #912CEE
purple3 purple3 rgb(125, 38, 205) #7D26CD
purple4 purple4 rgb( 85, 26, 139) #551A8B
purple1 purple1 rgb(155, 48, 255) #9B30FF
MediumPurple MediumPurple rgb(147, 112, 219) #9370DB
MediumPurple1 MediumPurple1 rgb(171, 130, 255) #AB82FF
MediumPurple2 MediumPurple2 rgb(159, 121, 238) #9F79EE
MediumPurple3 MediumPurple3 rgb(137, 104, 205) #8968CD
MediumPurple4 MediumPurple4 rgb( 93, 71, 139) #5D478B
DarkSlateBlue DarkSlateBlue rgb( 72, 61, 139) #483D8B
LightSlateBlue LightSlateBlue rgb(132, 112, 255) #8470FF
MediumSlateBlue MediumSlateBlue rgb(123, 104, 238) #7B68EE
SlateBlue SlateBlue rgb(106, 90, 205) #6A5ACD
SlateBlue1 SlateBlue1 rgb(131, 111, 255) #836FFF
SlateBlue2 SlateBlue2 rgb(122, 103, 238) #7A67EE
SlateBlue3 SlateBlue3 rgb(105, 89, 205) #6959CD
SlateBlue4 SlateBlue4 rgb( 71, 60, 139) #473C8B
GhostWhite GhostWhite rgb(248, 248, 255) #F8F8FF
lavender lavender rgb(230, 230, 250) #E6E6FA
blue blue rgb( 0, 0, 255) #0000FF
blue1 blue1 rgb( 0, 0, 255) #0000FF
blue2 blue2 rgb( 0, 0, 238) #0000EE
blue3 blue3 rgb( 0, 0, 205) #0000CD
MediumBlue MediumBlue rgb( 0, 0, 205) #0000CD
blue4 blue4 rgb( 0, 0, 139) #00008B
DarkBlue DarkBlue rgb( 0, 0, 139) #00008B
MidnightBlue MidnightBlue rgb( 25, 25, 112) #191970
navy navy rgb( 0, 0, 128) #000080
NavyBlue NavyBlue rgb( 0, 0, 128) #000080
RoyalBlue RoyalBlue rgb( 65, 105, 225) #4169E1
RoyalBlue1 RoyalBlue1 rgb( 72, 118, 255) #4876FF
RoyalBlue2 RoyalBlue2 rgb( 67, 110, 238) #436EEE
RoyalBlue3 RoyalBlue3 rgb( 58, 95, 205) #3A5FCD
RoyalBlue4 RoyalBlue4 rgb( 39, 64, 139) #27408B
CornflowerBlue CornflowerBlue rgb(100, 149, 237) #6495ED
LightSteelBlue LightSteelBlue rgb(176, 196, 222) #B0C4DE
LightSteelBlue1 LightSteelBlue1 rgb(202, 225, 255) #CAE1FF
LightSteelBlue2 LightSteelBlue2 rgb(188, 210, 238) #BCD2EE
LightSteelBlue3 LightSteelBlue3 rgb(162, 181, 205) #A2B5CD
LightSteelBlue4 LightSteelBlue4 rgb(110, 123, 139) #6E7B8B
SlateGray4 SlateGray4 rgb(108, 123, 139) #6C7B8B
SlateGray1 SlateGray1 rgb(198, 226, 255) #C6E2FF
SlateGray2 SlateGray2 rgb(185, 211, 238) #B9D3EE
SlateGray3 SlateGray3 rgb(159, 182, 205) #9FB6CD
LightSlateGray LightSlateGray rgb(119, 136, 153) #778899
LightSlateGrey LightSlateGrey rgb(119, 136, 153) #778899
SlateGray SlateGray rgb(112, 128, 144) #708090
SlateGrey SlateGrey rgb(112, 128, 144) #708090
DodgerBlue DodgerBlue rgb( 30, 144, 255) #1E90FF
DodgerBlue1 DodgerBlue1 rgb( 30, 144, 255) #1E90FF
DodgerBlue2 DodgerBlue2 rgb( 28, 134, 238) #1C86EE
DodgerBlue4 DodgerBlue4 rgb( 16, 78, 139) #104E8B
DodgerBlue3 DodgerBlue3 rgb( 24, 116, 205) #1874CD
AliceBlue AliceBlue rgb(240, 248, 255) #F0F8FF
SteelBlue4 SteelBlue4 rgb( 54, 100, 139) #36648B
SteelBlue SteelBlue rgb( 70, 130, 180) #4682B4
SteelBlue1 SteelBlue1 rgb( 99, 184, 255) #63B8FF
SteelBlue2 SteelBlue2 rgb( 92, 172, 238) #5CACEE
SteelBlue3 SteelBlue3 rgb( 79, 148, 205) #4F94CD
SkyBlue4 SkyBlue4 rgb( 74, 112, 139) #4A708B
SkyBlue1 SkyBlue1 rgb(135, 206, 255) #87CEFF
SkyBlue2 SkyBlue2 rgb(126, 192, 238) #7EC0EE
SkyBlue3 SkyBlue3 rgb(108, 166, 205) #6CA6CD
LightSkyBlue LightSkyBlue rgb(135, 206, 250) #87CEFA
LightSkyBlue4 LightSkyBlue4 rgb( 96, 123, 139) #607B8B
LightSkyBlue1 LightSkyBlue1 rgb(176, 226, 255) #B0E2FF
LightSkyBlue2 LightSkyBlue2 rgb(164, 211, 238) #A4D3EE
LightSkyBlue3 LightSkyBlue3 rgb(141, 182, 205) #8DB6CD
SkyBlue SkyBlue rgb(135, 206, 235) #87CEEB
LightBlue3 LightBlue3 rgb(154, 192, 205) #9AC0CD
DeepSkyBlue DeepSkyBlue rgb( 0, 191, 255) #00BFFF
DeepSkyBlue1 DeepSkyBlue1 rgb( 0, 191, 255) #00BFFF
DeepSkyBlue2 DeepSkyBlue2 rgb( 0, 178, 238) #00B2EE
DeepSkyBlue4 DeepSkyBlue4 rgb( 0, 104, 139) #00688B
DeepSkyBlue3 DeepSkyBlue3 rgb( 0, 154, 205) #009ACD
LightBlue1 LightBlue1 rgb(191, 239, 255) #BFEFFF
LightBlue2 LightBlue2 rgb(178, 223, 238) #B2DFEE
LightBlue LightBlue rgb(173, 216, 230) #ADD8E6
LightBlue4 LightBlue4 rgb(104, 131, 139) #68838B
PowderBlue PowderBlue rgb(176, 224, 230) #B0E0E6
CadetBlue1 CadetBlue1 rgb(152, 245, 255) #98F5FF
CadetBlue2 CadetBlue2 rgb(142, 229, 238) #8EE5EE
CadetBlue3 CadetBlue3 rgb(122, 197, 205) #7AC5CD
CadetBlue4 CadetBlue4 rgb( 83, 134, 139) #53868B
turquoise1 turquoise1 rgb( 0, 245, 255) #00F5FF
turquoise2 turquoise2 rgb( 0, 229, 238) #00E5EE
turquoise3 turquoise3 rgb( 0, 197, 205) #00C5CD
turquoise4 turquoise4 rgb( 0, 134, 139) #00868B
cadet blue cadet blue rgb( 95, 158, 160) #5F9EA0
CadetBlue CadetBlue rgb( 95, 158, 160) #5F9EA0
DarkTurquoise DarkTurquoise rgb( 0, 206, 209) #00CED1
azure azure rgb(240, 255, 255) #F0FFFF
azure1 azure1 rgb(240, 255, 255) #F0FFFF
LightCyan LightCyan rgb(224, 255, 255) #E0FFFF
LightCyan1 LightCyan1 rgb(224, 255, 255) #E0FFFF
azure2 azure2 rgb(224, 238, 238) #E0EEEE
LightCyan2 LightCyan2 rgb(209, 238, 238) #D1EEEE
PaleTurquoise1 PaleTurquoise1 rgb(187, 255, 255) #BBFFFF
PaleTurquoise PaleTurquoise rgb(175, 238, 238) #AFEEEE
PaleTurquoise2 PaleTurquoise2 rgb(174, 238, 238) #AEEEEE
DarkSlateGray1 DarkSlateGray1 rgb(151, 255, 255) #97FFFF
azure3 azure3 rgb(193, 205, 205) #C1CDCD
LightCyan3 LightCyan3 rgb(180, 205, 205) #B4CDCD
DarkSlateGray2 DarkSlateGray2 rgb(141, 238, 238) #8DEEEE
PaleTurquoise3 PaleTurquoise3 rgb(150, 205, 205) #96CDCD
DarkSlateGray3 DarkSlateGray3 rgb(121, 205, 205) #79CDCD
azure4 azure4 rgb(131, 139, 139) #838B8B
LightCyan4 LightCyan4 rgb(122, 139, 139) #7A8B8B
aqua aqua rgb( 0, 255, 255) #00FFFF
cyan cyan rgb( 0, 255, 255) #00FFFF
cyan1 cyan1 rgb( 0, 255, 255) #00FFFF
PaleTurquoise4 PaleTurquoise4 rgb(102, 139, 139) #668B8B
cyan2 cyan2 rgb( 0, 238, 238) #00EEEE
DarkSlateGray4 DarkSlateGray4 rgb( 82, 139, 139) #528B8B
cyan3 cyan3 rgb( 0, 205, 205) #00CDCD
cyan4 cyan4 rgb( 0, 139, 139) #008B8B
DarkCyan DarkCyan rgb( 0, 139, 139) #008B8B
teal teal rgb( 0, 128, 128) #008080
DarkSlateGray DarkSlateGray rgb( 47, 79, 79) #2F4F4F
DarkSlateGrey DarkSlateGrey rgb( 47, 79, 79) #2F4F4F
MediumTurquoise MediumTurquoise rgb( 72, 209, 204) #48D1CC
LightSeaGreen LightSeaGreen rgb( 32, 178, 170) #20B2AA
turquoise turquoise rgb( 64, 224, 208) #40E0D0
aquamarine4 aquamarine4 rgb( 69, 139, 116) #458B74
aquamarine aquamarine rgb(127, 255, 212) #7FFFD4
aquamarine1 aquamarine1 rgb(127, 255, 212) #7FFFD4
aquamarine2 aquamarine2 rgb(118, 238, 198) #76EEC6
aquamarine3 aquamarine3 rgb(102, 205, 170) #66CDAA
MediumAquamarine MediumAquamarine rgb(102, 205, 170) #66CDAA
MediumSpringGreen MediumSpringGreen rgb( 0, 250, 154) #00FA9A
MintCream MintCream rgb(245, 255, 250) #F5FFFA
SpringGreen SpringGreen rgb( 0, 255, 127) #00FF7F
SpringGreen1 SpringGreen1 rgb( 0, 255, 127) #00FF7F
SpringGreen2 SpringGreen2 rgb( 0, 238, 118) #00EE76
SpringGreen3 SpringGreen3 rgb( 0, 205, 102) #00CD66
SpringGreen4 SpringGreen4 rgb( 0, 139, 69) #008B45
MediumSeaGreen MediumSeaGreen rgb( 60, 179, 113) #3CB371
SeaGreen SeaGreen rgb( 46, 139, 87) #2E8B57
SeaGreen3 SeaGreen3 rgb( 67, 205, 128) #43CD80
SeaGreen1 SeaGreen1 rgb( 84, 255, 159) #54FF9F
SeaGreen4 SeaGreen4 rgb( 46, 139, 87) #2E8B57
SeaGreen2 SeaGreen2 rgb( 78, 238, 148) #4EEE94
MediumForestGreen MediumForestGreen rgb( 50, 129, 75) #32814B
honeydew honeydew rgb(240, 255, 240) #F0FFF0
honeydew1 honeydew1 rgb(240, 255, 240) #F0FFF0
honeydew2 honeydew2 rgb(224, 238, 224) #E0EEE0
DarkSeaGreen1 DarkSeaGreen1 rgb(193, 255, 193) #C1FFC1
DarkSeaGreen2 DarkSeaGreen2 rgb(180, 238, 180) #B4EEB4
PaleGreen1 PaleGreen1 rgb(154, 255, 154) #9AFF9A
PaleGreen PaleGreen rgb(152, 251, 152) #98FB98
honeydew3 honeydew3 rgb(193, 205, 193) #C1CDC1
LightGreen LightGreen rgb(144, 238, 144) #90EE90
PaleGreen2 PaleGreen2 rgb(144, 238, 144) #90EE90
DarkSeaGreen3 DarkSeaGreen3 rgb(155, 205, 155) #9BCD9B
DarkSeaGreen DarkSeaGreen rgb(143, 188, 143) #8FBC8F
PaleGreen3 PaleGreen3 rgb(124, 205, 124) #7CCD7C
honeydew4 honeydew4 rgb(131, 139, 131) #838B83
green1 green1 rgb( 0, 255, 0) #00FF00
lime lime rgb( 0, 255, 0) #00FF00
LimeGreen LimeGreen rgb( 50, 205, 50) #32CD32
DarkSeaGreen4 DarkSeaGreen4 rgb(105, 139, 105) #698B69
green2 green2 rgb( 0, 238, 0) #00EE00
PaleGreen4 PaleGreen4 rgb( 84, 139, 84) #548B54
green3 green3 rgb( 0, 205, 0) #00CD00
ForestGreen ForestGreen rgb( 34, 139, 34) #228B22
green4 green4 rgb( 0, 139, 0) #008B00
green green rgb( 0, 128, 0) #008000
DarkGreen DarkGreen rgb( 0, 100, 0) #006400
LawnGreen LawnGreen rgb(124, 252, 0) #7CFC00
chartreuse chartreuse rgb(127, 255, 0) #7FFF00
chartreuse1 chartreuse1 rgb(127, 255, 0) #7FFF00
chartreuse2 chartreuse2 rgb(118, 238, 0) #76EE00
chartreuse3 chartreuse3 rgb(102, 205, 0) #66CD00
chartreuse4 chartreuse4 rgb( 69, 139, 0) #458B00
GreenYellow GreenYellow rgb(173, 255, 47) #ADFF2F
DarkOliveGreen3 DarkOliveGreen3 rgb(162, 205, 90) #A2CD5A
DarkOliveGreen1 DarkOliveGreen1 rgb(202, 255, 112) #CAFF70
DarkOliveGreen2 DarkOliveGreen2 rgb(188, 238, 104) #BCEE68
DarkOliveGreen4 DarkOliveGreen4 rgb(110, 139, 61) #6E8B3D
DarkOliveGreen DarkOliveGreen rgb( 85, 107, 47) #556B2F
OliveDrab OliveDrab rgb(107, 142, 35) #6B8E23
OliveDrab1 OliveDrab1 rgb(192, 255, 62) #C0FF3E
OliveDrab2 OliveDrab2 rgb(179, 238, 58) #B3EE3A
OliveDrab3 OliveDrab3 rgb(154, 205, 50) #9ACD32
YellowGreen YellowGreen rgb(154, 205, 50) #9ACD32
OliveDrab4 OliveDrab4 rgb(105, 139, 34) #698B22
ivory ivory rgb(255, 255, 240) #FFFFF0
ivory1 ivory1 rgb(255, 255, 240) #FFFFF0
LightYellow LightYellow rgb(255, 255, 224) #FFFFE0
LightYellow1 LightYellow1 rgb(255, 255, 224) #FFFFE0
beige beige rgb(245, 245, 220) #F5F5DC
ivory2 ivory2 rgb(238, 238, 224) #EEEEE0
LightGoldenrodYellow LightGoldenrodYellow rgb(250, 250, 210) #FAFAD2
LightYellow2 LightYellow2 rgb(238, 238, 209) #EEEED1
ivory3 ivory3 rgb(205, 205, 193) #CDCDC1
LightYellow3 LightYellow3 rgb(205, 205, 180) #CDCDB4
ivory4 ivory4 rgb(139, 139, 131) #8B8B83
LightYellow4 LightYellow4 rgb(139, 139, 122) #8B8B7A
yellow yellow rgb(255, 255, 0) #FFFF00
yellow1 yellow1 rgb(255, 255, 0) #FFFF00
yellow2 yellow2 rgb(238, 238, 0) #EEEE00
yellow3 yellow3 rgb(205, 205, 0) #CDCD00
yellow4 yellow4 rgb(139, 139, 0) #8B8B00
olive olive rgb(128, 128, 0) #808000
DarkKhaki DarkKhaki rgb(189, 183, 107) #BDB76B
khaki2 khaki2 rgb(238, 230, 133) #EEE685
LemonChiffon4 LemonChiffon4 rgb(139, 137, 112) #8B8970
khaki1 khaki1 rgb(255, 246, 143) #FFF68F
khaki3 khaki3 rgb(205, 198, 115) #CDC673
khaki4 khaki4 rgb(139, 134, 78) #8B864E
PaleGoldenrod PaleGoldenrod rgb(238, 232, 170) #EEE8AA
LemonChiffon LemonChiffon rgb(255, 250, 205) #FFFACD
LemonChiffon1 LemonChiffon1 rgb(255, 250, 205) #FFFACD
khaki khaki rgb(240, 230, 140) #F0E68C
LemonChiffon3 LemonChiffon3 rgb(205, 201, 165) #CDC9A5
LemonChiffon2 LemonChiffon2 rgb(238, 233, 191) #EEE9BF
MediumGoldenRod MediumGoldenRod rgb(209, 193, 102) #D1C166
cornsilk4 cornsilk4 rgb(139, 136, 120) #8B8878
gold gold rgb(255, 215, 0) #FFD700
gold1 gold1 rgb(255, 215, 0) #FFD700
gold2 gold2 rgb(238, 201, 0) #EEC900
gold3 gold3 rgb(205, 173, 0) #CDAD00
gold4 gold4 rgb(139, 117, 0) #8B7500
LightGoldenrod LightGoldenrod rgb(238, 221, 130) #EEDD82
LightGoldenrod4 LightGoldenrod4 rgb(139, 129, 76) #8B814C
LightGoldenrod1 LightGoldenrod1 rgb(255, 236, 139) #FFEC8B
LightGoldenrod3 LightGoldenrod3 rgb(205, 190, 112) #CDBE70
LightGoldenrod2 LightGoldenrod2 rgb(238, 220, 130) #EEDC82
cornsilk3 cornsilk3 rgb(205, 200, 177) #CDC8B1
cornsilk2 cornsilk2 rgb(238, 232, 205) #EEE8CD
cornsilk cornsilk rgb(255, 248, 220) #FFF8DC
cornsilk1 cornsilk1 rgb(255, 248, 220) #FFF8DC
goldenrod goldenrod rgb(218, 165, 32) #DAA520
goldenrod1 goldenrod1 rgb(255, 193, 37) #FFC125
goldenrod2 goldenrod2 rgb(238, 180, 34) #EEB422
goldenrod3 goldenrod3 rgb(205, 155, 29) #CD9B1D
goldenrod4 goldenrod4 rgb(139, 105, 20) #8B6914
DarkGoldenrod DarkGoldenrod rgb(184, 134, 11) #B8860B
DarkGoldenrod1 DarkGoldenrod1 rgb(255, 185, 15) #FFB90F
DarkGoldenrod2 DarkGoldenrod2 rgb(238, 173, 14) #EEAD0E
DarkGoldenrod3 DarkGoldenrod3 rgb(205, 149, 12) #CD950C
DarkGoldenrod4 DarkGoldenrod4 rgb(139, 101, 8) #8B6508
FloralWhite FloralWhite rgb(255, 250, 240) #FFFAF0
wheat2 wheat2 rgb(238, 216, 174) #EED8AE
OldLace OldLace rgb(253, 245, 230) #FDF5E6
wheat wheat rgb(245, 222, 179) #F5DEB3
wheat1 wheat1 rgb(255, 231, 186) #FFE7BA
wheat3 wheat3 rgb(205, 186, 150) #CDBA96
orange orange rgb(255, 165, 0) #FFA500
orange1 orange1 rgb(255, 165, 0) #FFA500
orange2 orange2 rgb(238, 154, 0) #EE9A00
orange3 orange3 rgb(205, 133, 0) #CD8500
orange4 orange4 rgb(139, 90, 0) #8B5A00
wheat4 wheat4 rgb(139, 126, 102) #8B7E66
moccasin moccasin rgb(255, 228, 181) #FFE4B5
PapayaWhip PapayaWhip rgb(255, 239, 213) #FFEFD5
NavajoWhite3 NavajoWhite3 rgb(205, 179, 139) #CDB38B
BlanchedAlmond BlanchedAlmond rgb(255, 235, 205) #FFEBCD
NavajoWhite NavajoWhite rgb(255, 222, 173) #FFDEAD
NavajoWhite1 NavajoWhite1 rgb(255, 222, 173) #FFDEAD
NavajoWhite2 NavajoWhite2 rgb(238, 207, 161) #EECFA1
NavajoWhite4 NavajoWhite4 rgb(139, 121, 94) #8B795E
AntiqueWhite4 AntiqueWhite4 rgb(139, 131, 120) #8B8378
AntiqueWhite AntiqueWhite rgb(250, 235, 215) #FAEBD7
tan tan rgb(210, 180, 140) #D2B48C
bisque4 bisque4 rgb(139, 125, 107) #8B7D6B
burlywood burlywood rgb(222, 184, 135) #DEB887
AntiqueWhite2 AntiqueWhite2 rgb(238, 223, 204) #EEDFCC
burlywood1 burlywood1 rgb(255, 211, 155) #FFD39B
burlywood3 burlywood3 rgb(205, 170, 125) #CDAA7D
burlywood2 burlywood2 rgb(238, 197, 145) #EEC591
AntiqueWhite1 AntiqueWhite1 rgb(255, 239, 219) #FFEFDB
burlywood4 burlywood4 rgb(139, 115, 85) #8B7355
AntiqueWhite3 AntiqueWhite3 rgb(205, 192, 176) #CDC0B0
DarkOrange DarkOrange rgb(255, 140, 0) #FF8C00
bisque2 bisque2 rgb(238, 213, 183) #EED5B7
bisque bisque rgb(255, 228, 196) #FFE4C4
bisque1 bisque1 rgb(255, 228, 196) #FFE4C4
bisque3 bisque3 rgb(205, 183, 158) #CDB79E
DarkOrange1 DarkOrange1 rgb(255, 127, 0) #FF7F00
linen linen rgb(250, 240, 230) #FAF0E6
DarkOrange2 DarkOrange2 rgb(238, 118, 0) #EE7600
DarkOrange3 DarkOrange3 rgb(205, 102, 0) #CD6600
DarkOrange4 DarkOrange4 rgb(139, 69, 0) #8B4500
peru peru rgb(205, 133, 63) #CD853F
tan1 tan1 rgb(255, 165, 79) #FFA54F
tan2 tan2 rgb(238, 154, 73) #EE9A49
tan3 tan3 rgb(205, 133, 63) #CD853F
tan4 tan4 rgb(139, 90, 43) #8B5A2B
PeachPuff PeachPuff rgb(255, 218, 185) #FFDAB9
PeachPuff1 PeachPuff1 rgb(255, 218, 185) #FFDAB9
PeachPuff4 PeachPuff4 rgb(139, 119, 101) #8B7765
PeachPuff2 PeachPuff2 rgb(238, 203, 173) #EECBAD
PeachPuff3 PeachPuff3 rgb(205, 175, 149) #CDAF95
SandyBrown SandyBrown rgb(244, 164, 96) #F4A460
seashell4 seashell4 rgb(139, 134, 130) #8B8682
seashell2 seashell2 rgb(238, 229, 222) #EEE5DE
seashell3 seashell3 rgb(205, 197, 191) #CDC5BF
chocolate chocolate rgb(210, 105, 30) #D2691E
chocolate1 chocolate1 rgb(255, 127, 36) #FF7F24
chocolate2 chocolate2 rgb(238, 118, 33) #EE7621
chocolate3 chocolate3 rgb(205, 102, 29) #CD661D
chocolate4 chocolate4 rgb(139, 69, 19) #8B4513
SaddleBrown SaddleBrown rgb(139, 69, 19) #8B4513
seashell seashell rgb(255, 245, 238) #FFF5EE
seashell1 seashell1 rgb(255, 245, 238) #FFF5EE
sienna4 sienna4 rgb(139, 71, 38) #8B4726
sienna sienna rgb(160, 82, 45) #A0522D
sienna1 sienna1 rgb(255, 130, 71) #FF8247
sienna2 sienna2 rgb(238, 121, 66) #EE7942
sienna3 sienna3 rgb(205, 104, 57) #CD6839
LightSalmon3 LightSalmon3 rgb(205, 129, 98) #CD8162
LightSalmon LightSalmon rgb(255, 160, 122) #FFA07A
LightSalmon1 LightSalmon1 rgb(255, 160, 122) #FFA07A
LightSalmon4 LightSalmon4 rgb(139, 87, 66) #8B5742
LightSalmon2 LightSalmon2 rgb(238, 149, 114) #EE9572
coral coral rgb(255, 127, 80) #FF7F50
OrangeRed OrangeRed rgb(255, 69, 0) #FF4500
OrangeRed1 OrangeRed1 rgb(255, 69, 0) #FF4500
OrangeRed2 OrangeRed2 rgb(238, 64, 0) #EE4000
OrangeRed3 OrangeRed3 rgb(205, 55, 0) #CD3700
OrangeRed4 OrangeRed4 rgb(139, 37, 0) #8B2500
DarkSalmon DarkSalmon rgb(233, 150, 122) #E9967A
salmon1 salmon1 rgb(255, 140, 105) #FF8C69
salmon2 salmon2 rgb(238, 130, 98) #EE8262
salmon3 salmon3 rgb(205, 112, 84) #CD7054
salmon4 salmon4 rgb(139, 76, 57) #8B4C39
coral1 coral1 rgb(255, 114, 86) #FF7256
coral2 coral2 rgb(238, 106, 80) #EE6A50
coral3 coral3 rgb(205, 91, 69) #CD5B45
coral4 coral4 rgb(139, 62, 47) #8B3E2F
tomato4 tomato4 rgb(139, 54, 38) #8B3626
tomato tomato rgb(255, 99, 71) #FF6347
tomato1 tomato1 rgb(255, 99, 71) #FF6347
tomato2 tomato2 rgb(238, 92, 66) #EE5C42
tomato3 tomato3 rgb(205, 79, 57) #CD4F39
MistyRose4 MistyRose4 rgb(139, 125, 123) #8B7D7B
MistyRose2 MistyRose2 rgb(238, 213, 210) #EED5D2
MistyRose MistyRose rgb(255, 228, 225) #FFE4E1
MistyRose1 MistyRose1 rgb(255, 228, 225) #FFE4E1
salmon salmon rgb(250, 128, 114) #FA8072
MistyRose3 MistyRose3 rgb(205, 183, 181) #CDB7B5
white white rgb(255, 255, 255) #FFFFFF
gray100 gray100 rgb(255, 255, 255) #FFFFFF
grey100 grey100 rgb(255, 255, 255) #FFFFFF
grey100 grey100 rgb(255, 255, 255) #FFFFFF
gray99 gray99 rgb(252, 252, 252) #FCFCFC
grey99 grey99 rgb(252, 252, 252) #FCFCFC
gray98 gray98 rgb(250, 250, 250) #FAFAFA
grey98 grey98 rgb(250, 250, 250) #FAFAFA
gray97 gray97 rgb(247, 247, 247) #F7F7F7
grey97 grey97 rgb(247, 247, 247) #F7F7F7
gray96 gray96 rgb(245, 245, 245) #F5F5F5
grey96 grey96 rgb(245, 245, 245) #F5F5F5
WhiteSmoke WhiteSmoke rgb(245, 245, 245) #F5F5F5
gray95 gray95 rgb(242, 242, 242) #F2F2F2
grey95 grey95 rgb(242, 242, 242) #F2F2F2
gray94 gray94 rgb(240, 240, 240) #F0F0F0
grey94 grey94 rgb(240, 240, 240) #F0F0F0
gray93 gray93 rgb(237, 237, 237) #EDEDED
grey93 grey93 rgb(237, 237, 237) #EDEDED
gray92 gray92 rgb(235, 235, 235) #EBEBEB
grey92 grey92 rgb(235, 235, 235) #EBEBEB
gray91 gray91 rgb(232, 232, 232) #E8E8E8
grey91 grey91 rgb(232, 232, 232) #E8E8E8
gray90 gray90 rgb(229, 229, 229) #E5E5E5
grey90 grey90 rgb(229, 229, 229) #E5E5E5
gray89 gray89 rgb(227, 227, 227) #E3E3E3
grey89 grey89 rgb(227, 227, 227) #E3E3E3
gray88 gray88 rgb(224, 224, 224) #E0E0E0
grey88 grey88 rgb(224, 224, 224) #E0E0E0
gray87 gray87 rgb(222, 222, 222) #DEDEDE
grey87 grey87 rgb(222, 222, 222) #DEDEDE
gainsboro gainsboro rgb(220, 220, 220) #DCDCDC
gray86 gray86 rgb(219, 219, 219) #DBDBDB
grey86 grey86 rgb(219, 219, 219) #DBDBDB
gray85 gray85 rgb(217, 217, 217) #D9D9D9
grey85 grey85 rgb(217, 217, 217) #D9D9D9
gray84 gray84 rgb(214, 214, 214) #D6D6D6
grey84 grey84 rgb(214, 214, 214) #D6D6D6
gray83 gray83 rgb(212, 212, 212) #D4D4D4
grey83 grey83 rgb(212, 212, 212) #D4D4D4
LightGray LightGray rgb(211, 211, 211) #D3D3D3
LightGrey LightGrey rgb(211, 211, 211) #D3D3D3
gray82 gray82 rgb(209, 209, 209) #D1D1D1
grey82 grey82 rgb(209, 209, 209) #D1D1D1
gray81 gray81 rgb(207, 207, 207) #CFCFCF
grey81 grey81 rgb(207, 207, 207) #CFCFCF
gray80 gray80 rgb(204, 204, 204) #CCCCCC
grey80 grey80 rgb(204, 204, 204) #CCCCCC
gray79 gray79 rgb(201, 201, 201) #C9C9C9
grey79 grey79 rgb(201, 201, 201) #C9C9C9
gray78 gray78 rgb(199, 199, 199) #C7C7C7
grey78 grey78 rgb(199, 199, 199) #C7C7C7
gray77 gray77 rgb(196, 196, 196) #C4C4C4
grey77 grey77 rgb(196, 196, 196) #C4C4C4
gray76 gray76 rgb(194, 194, 194) #C2C2C2
grey76 grey76 rgb(194, 194, 194) #C2C2C2
silver silver rgb(192, 192, 192) #C0C0C0
gray75 gray75 rgb(191, 191, 191) #BFBFBF
grey75 grey75 rgb(191, 191, 191) #BFBFBF
gray74 gray74 rgb(189, 189, 189) #BDBDBD
grey74 grey74 rgb(189, 189, 189) #BDBDBD
gray73 gray73 rgb(186, 186, 186) #BABABA
grey73 grey73 rgb(186, 186, 186) #BABABA
gray72 gray72 rgb(184, 184, 184) #B8B8B8
grey72 grey72 rgb(184, 184, 184) #B8B8B8
gray71 gray71 rgb(181, 181, 181) #B5B5B5
grey71 grey71 rgb(181, 181, 181) #B5B5B5
gray70 gray70 rgb(179, 179, 179) #B3B3B3
grey70 grey70 rgb(179, 179, 179) #B3B3B3
gray69 gray69 rgb(176, 176, 176) #B0B0B0
grey69 grey69 rgb(176, 176, 176) #B0B0B0
gray68 gray68 rgb(173, 173, 173) #ADADAD
grey68 grey68 rgb(173, 173, 173) #ADADAD
gray67 gray67 rgb(171, 171, 171) #ABABAB
grey67 grey67 rgb(171, 171, 171) #ABABAB
DarkGray DarkGray rgb(169, 169, 169) #A9A9A9
DarkGrey DarkGrey rgb(169, 169, 169) #A9A9A9
gray66 gray66 rgb(168, 168, 168) #A8A8A8
grey66 grey66 rgb(168, 168, 168) #A8A8A8
gray65 gray65 rgb(166, 166, 166) #A6A6A6
grey65 grey65 rgb(166, 166, 166) #A6A6A6
gray64 gray64 rgb(163, 163, 163) #A3A3A3
grey64 grey64 rgb(163, 163, 163) #A3A3A3
gray63 gray63 rgb(161, 161, 161) #A1A1A1
grey63 grey63 rgb(161, 161, 161) #A1A1A1
gray62 gray62 rgb(158, 158, 158) #9E9E9E
grey62 grey62 rgb(158, 158, 158) #9E9E9E
gray61 gray61 rgb(156, 156, 156) #9C9C9C
grey61 grey61 rgb(156, 156, 156) #9C9C9C
gray60 gray60 rgb(153, 153, 153) #999999
grey60 grey60 rgb(153, 153, 153) #999999
gray59 gray59 rgb(150, 150, 150) #969696
grey59 grey59 rgb(150, 150, 150) #969696
gray58 gray58 rgb(148, 148, 148) #949494
grey58 grey58 rgb(148, 148, 148) #949494
gray57 gray57 rgb(145, 145, 145) #919191
grey57 grey57 rgb(145, 145, 145) #919191
gray56 gray56 rgb(143, 143, 143) #8F8F8F
grey56 grey56 rgb(143, 143, 143) #8F8F8F
gray55 gray55 rgb(140, 140, 140) #8C8C8C
grey55 grey55 rgb(140, 140, 140) #8C8C8C
gray54 gray54 rgb(138, 138, 138) #8A8A8A
grey54 grey54 rgb(138, 138, 138) #8A8A8A
gray53 gray53 rgb(135, 135, 135) #878787
grey53 grey53 rgb(135, 135, 135) #878787
gray52 gray52 rgb(133, 133, 133) #858585
grey52 grey52 rgb(133, 133, 133) #858585
gray51 gray51 rgb(130, 130, 130) #828282
grey51 grey51 rgb(130, 130, 130) #828282
fractal fractal rgb(128, 128, 128) #808080
gray50 gray50 rgb(127, 127, 127) #7F7F7F
grey50 grey50 rgb(127, 127, 127) #7F7F7F
gray gray rgb(126, 126, 126) #7E7E7E
gray49 gray49 rgb(125, 125, 125) #7D7D7D
grey49 grey49 rgb(125, 125, 125) #7D7D7D
gray48 gray48 rgb(122, 122, 122) #7A7A7A
grey48 grey48 rgb(122, 122, 122) #7A7A7A
gray47 gray47 rgb(120, 120, 120) #787878
grey47 grey47 rgb(120, 120, 120) #787878
gray46 gray46 rgb(117, 117, 117) #757575
grey46 grey46 rgb(117, 117, 117) #757575
gray45 gray45 rgb(115, 115, 115) #737373
grey45 grey45 rgb(115, 115, 115) #737373
gray44 gray44 rgb(112, 112, 112) #707070
grey44 grey44 rgb(112, 112, 112) #707070
gray43 gray43 rgb(110, 110, 110) #6E6E6E
grey43 grey43 rgb(110, 110, 110) #6E6E6E
gray42 gray42 rgb(107, 107, 107) #6B6B6B
grey42 grey42 rgb(107, 107, 107) #6B6B6B
DimGray DimGray rgb(105, 105, 105) #696969
DimGrey DimGrey rgb(105, 105, 105) #696969
gray41 gray41 rgb(105, 105, 105) #696969
grey41 grey41 rgb(105, 105, 105) #696969
gray40 gray40 rgb(102, 102, 102) #666666
grey40 grey40 rgb(102, 102, 102) #666666
gray39 gray39 rgb( 99, 99, 99) #636363
grey39 grey39 rgb( 99, 99, 99) #636363
gray38 gray38 rgb( 97, 97, 97) #616161
grey38 grey38 rgb( 97, 97, 97) #616161
gray37 gray37 rgb( 94, 94, 94) #5E5E5E
grey37 grey37 rgb( 94, 94, 94) #5E5E5E
gray36 gray36 rgb( 92, 92, 92) #5C5C5C
grey36 grey36 rgb( 92, 92, 92) #5C5C5C
gray35 gray35 rgb( 89, 89, 89) #595959
grey35 grey35 rgb( 89, 89, 89) #595959
gray34 gray34 rgb( 87, 87, 87) #575757
grey34 grey34 rgb( 87, 87, 87) #575757
gray33 gray33 rgb( 84, 84, 84) #545454
grey33 grey33 rgb( 84, 84, 84) #545454
gray32 gray32 rgb( 82, 82, 82) #525252
grey32 grey32 rgb( 82, 82, 82) #525252
gray31 gray31 rgb( 79, 79, 79) #4F4F4F
grey31 grey31 rgb( 79, 79, 79) #4F4F4F
gray30 gray30 rgb( 77, 77, 77) #4D4D4D
grey30 grey30 rgb( 77, 77, 77) #4D4D4D
gray29 gray29 rgb( 74, 74, 74) #4A4A4A
grey29 grey29 rgb( 74, 74, 74) #4A4A4A
gray28 gray28 rgb( 71, 71, 71) #474747
grey28 grey28 rgb( 71, 71, 71) #474747
gray27 gray27 rgb( 69, 69, 69) #454545
grey27 grey27 rgb( 69, 69, 69) #454545
gray26 gray26 rgb( 66, 66, 66) #424242
grey26 grey26 rgb( 66, 66, 66) #424242
gray25 gray25 rgb( 64, 64, 64) #404040
grey25 grey25 rgb( 64, 64, 64) #404040
gray24 gray24 rgb( 61, 61, 61) #3D3D3D
grey24 grey24 rgb( 61, 61, 61) #3D3D3D
gray23 gray23 rgb( 59, 59, 59) #3B3B3B
grey23 grey23 rgb( 59, 59, 59) #3B3B3B
gray22 gray22 rgb( 56, 56, 56) #383838
grey22 grey22 rgb( 56, 56, 56) #383838
gray21 gray21 rgb( 54, 54, 54) #363636
grey21 grey21 rgb( 54, 54, 54) #363636
gray20 gray20 rgb( 51, 51, 51) #333333
grey20 grey20 rgb( 51, 51, 51) #333333
gray19 gray19 rgb( 48, 48, 48) #303030
grey19 grey19 rgb( 48, 48, 48) #303030
gray18 gray18 rgb( 46, 46, 46) #2E2E2E
grey18 grey18 rgb( 46, 46, 46) #2E2E2E
gray17 gray17 rgb( 43, 43, 43) #2B2B2B
grey17 grey17 rgb( 43, 43, 43) #2B2B2B
gray16 gray16 rgb( 41, 41, 41) #292929
grey16 grey16 rgb( 41, 41, 41) #292929
gray15 gray15 rgb( 38, 38, 38) #262626
grey15 grey15 rgb( 38, 38, 38) #262626
gray14 gray14 rgb( 36, 36, 36) #242424
grey14 grey14 rgb( 36, 36, 36) #242424
gray13 gray13 rgb( 33, 33, 33) #212121
grey13 grey13 rgb( 33, 33, 33) #212121
gray12 gray12 rgb( 31, 31, 31) #1F1F1F
grey12 grey12 rgb( 31, 31, 31) #1F1F1F
gray11 gray11 rgb( 28, 28, 28) #1C1C1C
grey11 grey11 rgb( 28, 28, 28) #1C1C1C
gray10 gray10 rgb( 26, 26, 26) #1A1A1A
grey10 grey10 rgb( 26, 26, 26) #1A1A1A
gray9 gray9 rgb( 23, 23, 23) #171717
grey9 grey9 rgb( 23, 23, 23) #171717
gray8 gray8 rgb( 20, 20, 20) #141414
grey8 grey8 rgb( 20, 20, 20) #141414
gray7 gray7 rgb( 18, 18, 18) #121212
grey7 grey7 rgb( 18, 18, 18) #121212
gray6 gray6 rgb( 15, 15, 15) #0F0F0F
grey6 grey6 rgb( 15, 15, 15) #0F0F0F
gray5 gray5 rgb( 13, 13, 13) #0D0D0D
grey5 grey5 rgb( 13, 13, 13) #0D0D0D
gray4 gray4 rgb( 10, 10, 10) #0A0A0A
grey4 grey4 rgb( 10, 10, 10) #0A0A0A
gray3 gray3 rgb( 8, 8, 8) #080808
grey3 grey3 rgb( 8, 8, 8) #080808
gray2 gray2 rgb( 5, 5, 5) #050505
grey2 grey2 rgb( 5, 5, 5) #050505
gray1 gray1 rgb( 3, 3, 3) #030303
grey1 grey1 rgb( 3, 3, 3) #030303
black black rgb( 0, 0, 0) #000000
gray0 gray0 rgb( 0, 0, 0) #000000
grey0 grey0 rgb( 0, 0, 0) #000000
opaque opaque rgb( 0, 0, 0) #000000
none none rgba( 0, 0, 0, 0.0) #00000000
transparent transparent rgba( 0, 0, 0, 0.0) #00000000

How to specify a color with transparency

To specify a translucent color, use 'rgba()', 'hsla()' or 'hsba()'.

For example, I want to use the color DarkViolet with translucency, that is, with an alpha channel.

First, I need to find the RGB value of the given color. This can be done in the table above, or with the command:

magick -list color | grep -i COLOR-NAME

For example:

magick -list color | grep -i DarkViolet

The result is:

DarkViolet            srgb(148,0,211)                               SVG X11 XPM

For a color to be transparent, use 'rgba()' with four digits, the first three being the srgb digits, in this case “(148,0,211)” and the last digit being the transparency level, ranging from 0 (fully transparent) up to 1 (no transparency).

An example of a command using a partially transparent color:

magick IMAGE.jpg -pointsize 72 -fill 'rgba(148,0,211,0.5)' -annotate +650+150 'zaLinux.ru' test.jpg

Color with transparency can be used for any purpose: canvas color, text color, text background color (undercolor), primitives.

The following command uses text with transparency for the caption and for the background of the text:

magick IMAGE.jpg -undercolor 'rgba(148,0,211,0.1)' -pointsize 72 -fill 'rgba(0,0,128,0.5)' -font Liberation-Serif -annotate +650+450 'zaLinux.ru' test66.jpg

Note that when saving in a format that supports transparency (eg PNG), transparency will be preserved, but when saved in formats that do not support transparency (eg JPEG), transparency will be lost.

Reference to file with option value

As an argument to any option, you can specify a link to a file that actually contains the value assigned to this option. A link to a file is specified as the @ symbol followed by the file name.

This is especially true for options that can have very long arguments, such as “-set”, “-sparse-color”, “-distort” or “-morphology”.

Below are examples of how @ can be used to specify the path to a font with the -font option, or a text file with the -annotate option.

LINK

LINK

You can also use the @ symbol instead of a filename to specify a file that lists filenames. In this case, all specified files will be processed.

Finally, linking to a file using the @ symbol can be used with the special image type “label:” and “caption:”. In this case, the text for the image data will be read from the specified file.

LINK

imagemagick_add_text_20

In all cases, if there is no file specified by the @ symbol, the line after this symbol will be interpreted literally, and not as a file name.

3. View image properties

How to get image properties

To view the properties of the IMAGE.jpg file, use the command:

magick IMAGE.jpg info:-

Or:

magick IMAGE.jpg -identify null:

The previous two commands will show the same result.

To display the most detailed information about an image, including metadata and color channel statistics, add the -verbose option:

magick IMAGE.jpg -verbose info:-

How to check the quality level of a JPG

How to know the quality of a JPG? Is it possible to determine the JPEG quality level?

When saving a JPG file using GIMP, you can adjust the quality with which the file is saved, values from 0 to 100 are available.

To view the quality of the IMAGE.jpg image, run the following command:

magick IMAGE.jpg -format '%Q' info:-

A number from 0 to 100 will be displayed indicating the quality of the image.

What does JPEG quality level mean?

JPEG is a lossy format. Every time you save the same JPEG image, regardless of the quality level, the actual image quality is reduced. So even if you get the quality level from the file, you won't be able to keep the same quality when resaving the JPEG (even with quality=100).

You should save your JPEG as high quality as you can afford in terms of file size. Or use a lossless format like PNG.

Low quality JPEG files do not simply become more blocky. Instead color depth is reduced and the detail of sections of the image are removed. You can't rely on lower quality images being blocky and looking ok at smaller sizes.

According to the JFIF specification, the quality number (0-100) is not stored in the image header, although the horizontal and vertical pixel density is preserved.

The JPEG compression algorithm has some parameters that affect the quality of the resulting image.

One such parameter is the quantization tables, which determine how many bits will be used for each coefficient. Different programs use different quantization tables.

Some programs allow the user to set the quality level from 0 to 100. But there is no general definition for this number. An image made in Photoshop at 60% quality is 46 KB, while an image created in GIMP is only 26 KB.

The quantization tables also differ.

There are other options like subsampling, dct method etc.

So you can't describe them all by one quality level number, and you can't compare the quality of JPEG images by just one number, especially between files saved by different programs.

Compare the quality of an image with a size of 4000 × 2252 pixels saved at different quality levels.

Close up JPG with quality 92:

Close up JPG with quality 20:

Close up JPG with quality 10:

As you can see, even up to level 20 the quality is still not so bad, although at level 10 distortion is already strong.

In addition to the quality level, the quality of the image itself is also affected by its size in pixels. For example, the same image, but already saved with a resolution of 1000 × 563 pixels. This is a highly approximate image fragment similar to the previous ones:

As you can see, the quality of the transmitted small details was much more affected by the decrease in the number of pixels.

How to find out the number of unique colors in an image

To count the number of unique colors in the IMAGE.jpg image, use the command:

magick IMAGE.jpg -format '%k' info:-

Please note that all commands in this article can apply not only to JPG files, but also to other formats (if applicable):

How to find out the size of an image

To view the size of the image IMAGE.jpg in pixels, use the command:

magick IMAGE.jpg -format '%G' info:-

How to view image class and color space

To display the image class and its color space of IMAGE.jpg, use the command:

magick IMAGE.jpg -format '%r' info:-

How to view image depth

To display the color depth of the IMAGE.jpg image, use the command:

magick IMAGE.jpg -format '%z' info:-

-format option arguments

The examples above used the -format option, after which you can specify what kind of information you want to view. Adding the -verbose option causes almost all data to be shown, with the exception of some values that are calculated (rather than contained in the image data). For a complete list of available options for the -format option, see the following page: https://imagemagick.org/script/escape.php

Online service for displaying information about images

If you are a Windows user, or you don't want to install ImageMagick (or just delve into the command line), then you can use the following free service: View the JPG quality level (image compression rate): https://suip.biz/?act=show-image-compression-quality

This service will show the image quality level, number of unique colors, resolution and all other data that the previous commands shown in this article output.

Mirror: https://w-e-b.site/?act=show-image-compression-quality

4. How to convert images to any formats in Linux

How to convert images on the Linux command line

You can view the full list of supported formats with the command

magick -list format

Also at the end of the article is a table with a complete list of supported file formats and their brief description.

To convert one image to any other, run the following command:

magick PICTURE RESULT

Note: if you get an error that the “magick” command was not found, then use the “convert” command instead. An explanation will be given below.

The program will automatically detect the original image format.

As for the output file format, it is determined by the extension specified in the previous command.

For example:

magick IMAGE.jpg RESULT.png

The following command will convert the image.png file to JPG format and save the new image to the image.jpg file:

magick image.png image.jpg

You can also convert dynamic images (such as GIF files) to video clips (avi, 3gp, webm, wmv, flv, mkv, mpg, webm, m2v, m4v, mov, mp4, mpeg and others).

You can also convert video formats avi, 3gp, webm, wmv, flv, mkv, mpg, webm, m2v, m4v, mov, mp4, mpeg and others to GIF files.

How to convert PDF to JPG

Use magick like this:

magick input.pdf output.jpg

For good quality use these options

magick -density 300 -quality 100 in.pdf out.jpg

If you encounter errors, then the following articles may help you:

How to convert JPG to PDF

To convert a single image to PDF, run the following command:

magick PICTURE.jpg RESULT.pdf

Example:

magick PL48536179-5.jpg out.pdf

You can specify multiple input .jpg files at once, for example:

magick PL48536179-5.jpg PL48536179-6.jpg PL48536179-7.jpg out.pdf

They will be added one by one to the generated PDF file.

If there are many files and they have a common prefix, then you can use the wildcard character * to add several files at once:

magick PL48536179* out.pdf

Or like this:

magick PL*.jpg out.pdf

The following command will create a PDF file from all JPG files in the current directory:

magick *.jpg out.pdf

By default, a PDF file is created in the highest quality. If you want to reduce the size of the output file, then specify the -quality option with a value less than 100, for example:

magick -quality 70 PL*.jpg out2.pdf

As you can see, the size of the PDF file has indeed decreased:

Bulk image conversion

Bulk image conversion

The article “How to convert images to any formats in Linux” shows how you can easily convert an image from one format to another using the magick program (hundreds of formats are supported).

The magick utility is great for bulk conversion and converting a large number of files.

Suppose there is a task to convert all JPG files in the current directory so that they are converted to PNG, HEIF or another format and saved in the specified folder, while each file must keep its own name.

First, let's note that in order not to specify each file separately, we will use “Wildcards in the file name”, that is, we will specify “*.jpg” as the input file.

As the output file, we will use “Specifying a file name pattern”.

Some “properties” must be defined in a special way in order to be used. For example, only “properties” prefixed with “filename:” can be used to change the output filename of an image.

Let's create a “png” directory:

mkdir png

The following command reads all the .jpg files in the current directory one by one, converts them to PNG format, and saves them to the “png” directory with the same names:

magick *.jpg -set filename:currentfile '%t' 'png/%[filename:currentfile].png'

Why does ImageMagick save all images to one file?

Suppose you need to solve a similar problem, but convert files to another format, for example, one of GIF, MIFF, TIFF, PDF, MNG, HEIF or HEIC.

See also: How to enable saving photos in HEIC (HEIF) format in Android and whether it should be done

The program as a whole will perform the specified task, but you will find that all images are saved in one file. The matter is that all specified formats support files with several pictures.

Magick's default behavior is to save all images to a single file if the format supports it. To change this default behavior, use the “+adjoin” option

For example, the following command will convert all images to .heif format and store the individual files in the “heif” directory:

mkdir heif
magick *.jpg -set filename:currentfile '%t' +adjoin 'heif/%[filename:currentfile].heif'

How to convert photos and reduce their size at the same time

You can combine image conversion with image resizing. For example, the following command will reduce all JPEG files in the current directory to 1000 pixels and convert them to HEIF format, then save them all to the “heif” folder with the original file name, to which the new photo resolution and new file extension will be added:

magick '*.jpg[1000x>]' -set filename:currentfile '%t-%wx%h' +adjoin 'heif/%[filename:currentfile].heif'

To avoid adding a new photo resolution, use the following command (the old name will be kept, but with a new filename extension):

magick '*.jpg[1000x>]' -set filename:currentfile '%t' +adjoin 'heif/%[filename:currentfile].heif'

Instead of changing the resolution of a photo, you can keep its size but increase the compression ratio (reduce image quality) by using the -quality option. The following command will read all JPEG files, compress them with quality 40 and convert them to HEIF format, then save them all to the “heif” folder with the original file name (only the extension will change):

magick '*.jpg' -quality 40 -set filename:currentfile '%t' +adjoin 'heif/%[filename:currentfile].heif'

For details on resizing and compressing photos, see the article: How to reduce image size. Bulk photo scaling and resizing on the command line.

Convert images to all formats online

If you do not want to install the ImageMagick package, then you can use online image conversion to any format. This is a free online service, you just need to specify the image to be converted and select the desired format of the new file.

Links:

5. How to reduce image size. Bulk photo scaling and resizing on the command line

How to reduce image size

You can reduce the image size in several ways:

1. Select lossy image encoding format (JPEG)

2. Increase the level of image compression (for images compressed with loss of quality, this will lead to a deterioration in the appearance of the image, for images compressed without quality loss, this will mean longer processing of the image)

3. Reduce the image size in pixels. This will affect the clarity of the image and the ability to see fine details.

How to resize an image on the Linux command line

To specify the image size in pixels, use the magick utility with -scale PIXELS option. This option sets the width of the output image, as for the height, it will be selected automatically to maintain the original aspect ratio of the image.

Command example:

magick IMAGE.jpg -scale 150 COMPRESSED.jpg

If you want the image to resize only if it is larger than a certain size, then use the -scale option with a greater than sign (>), which must be enclosed in quotes along with the number. For example, the following command will only shrink an image to 500 pixels wide if the image is larger than 500 pixels.

magick IMAGE.jpg -scale '>500' size.jpg

If you use the command without the greater than sign (>), the image size will be set to 500 pixels, regardless of its initial size. That is, the image size is less than 500 pixels, then its width will be set to 500 pixels with the following command:

magick IMAGE.jpg -scale '500' size.jpg

See the Image Geometry section for details.

The -scale option enlarges images using pixel averaging. When you reduce an image, pixels are simply removed. No image filters are applied.

In addition to this option, there are also the following:

  • -resize GEOMETRY – resizes the image, takes into account filters (option -filter)
  • -sample GEOMETRY – modifies the image with pixel subsampling and pixel replication respectively. Doesn't take into account filters. The key feature of -sample is that no new colors are added to the resulting image, although some colors may disappear.
  • -resample GEOMETRY – changes image resolution, works with dpi

When processing a large number of photos, to save computer resources (primarily RAM), use Image resizing while reading.

How to set image compression level in Linux command line

When converting to some formats, you can use the -quality VALUE option. For VALUE, enter a number between 1 (worst quality) and 100 (best quality). For example:

magick IMAGE.jpg -quality 40 COMPRESSED.jpg

The -quality option is applicable for JPEG, MIFF, TIFF, PNG, MNG formats.

For lossy image formats (JPEG), this option sets the degree of quality – the lower the quality, the greater the loss in compression, but also the smaller the size.

For other lossless encoding formats, this option sets the compression ratio.

For the JPEG and MPEG image formats, quality is 1 (lowest image quality and highest compression) to 100 (best quality but least effective compression). The default is to use the estimated quality of your input image if it can be determined, otherwise 92. When the quality is greater than 90, then the chroma channels are not downsampled. Use the -sampling-factor option to specify the factors for chroma downsampling.

For the JPEG-2000 image format, quality is mapped using a non-linear equation to the compression ratio required by the Jasper library. This non-linear equation is intended to loosely approximate the quality provided by the JPEG v1 format. The default quality value 100, a request for non-lossy compression. A quality of 75 results in a request for 16:1 compression.

For the MNG and PNG image formats, the quality value sets the zlib compression level (quality / 10) and filter-type (quality % 10). The default PNG "quality" is 75, which means compression level 7 with adaptive PNG filtering, unless the image has a color map, in which case it means compression level 7 with no PNG filtering.

For compression level 0 (quality value less than 10), the Huffman-only strategy is used, which is fastest but not necessarily the worst compression.

If filter-type is 4 or less, the specified PNG filter-type is used for all scanlines:

0 none
1 sub
2 up
3 average
4 Paeth

If filter-type is 5, adaptive filtering is used when quality is greater than 50 and the image does not have a color map, otherwise no filtering is used.

If filter-type is 6, adaptive filtering with minimum-sum-of-absolute-values is used.

Only if the output is MNG, if filter-type is 7, the LOCO color transformation (intrapixel differencing) and adaptive filtering with minimum-sum-of-absolute-values are used.

If the filter-type is 8 the zlib Z_RLE compression strategy (or the Z_HUFFMAN_ONLY strategy, when compression level is 0) is used with adaptive PNG filtering.

If the filter-type is 9 the zlib Z_RLE compression strategy (or the Z_HUFFMAN_ONLY strategy, when compression level is 0) is used with no PNG filtering.

The quality setting has no effect on the appearance or signature of PNG and MNG images, since the compression is always lossless.

Not all combinations of compression level, strategy, and PNG filter type can be obtained using the -quality option. For more precise control, you can use the PNG:compression-level=N, PNG:compression-strategy=N, and PNG:compression-filter=N defines, respectively, instead. See -define. Values from the -defines optoin take precedence over values from the -quality option.

For further information, see the PNG specification.

For the MIFF and TIFF image formats, quality/10 is the Zip/BZip compression level, which is 0 (worst but fastest compression) to 9 (best but slowest). It has no effect on the image appearance, since the compression is always lossless.

For the BPG image format, quality/2 is the actual BPG compression level (range from 0 to 51).

Bulk photo resizing on the command line

The magick utility is great for bulk conversion of a large number of files.

Suppose there is a task to process all JPG files in the current directory in such a way as to reduce their size to 100 pixels and save them in the “preview” folder, while each file must keep its own name.

First, let's note that in order not to specify each file separately, we will use “Wildcards in the file name”, that is, we will specify “*.jpg” as the input file.

Also, instead of the -scale option, we will use “Image resizing while reading”, i.e. the desired image size will be indicated in square brackets after the filename pattern. So the filename becomes “*.jpg[100x]” because we want to resize to 100px.

Please note that this approach of replacing -scale with changing the image during reading will save a lot of computer resources (RAM), since all images will be processed sequentially, without first reading them into RAM.

As the output file, we will use “Specifying a file name pattern”.

Some “properties” must be defined in a special way in order to be used. For example, only “properties” prefixed with “filename:” can be used to change the output filename of an image.

Let's create a “preview” directory:

mkdir preview

The following command reads all the .jpg files in the current directory one by one, resizes them to 100 pixels, and saves them to the “preview” directory with the same names:

magick *.jpg[100x] -set filename:currentfile '%t' 'preview/%[filename:currentfile].jpg'

%t means original filename without extension. A list of possible attributes and their conventions in the form of escaped characters can be found at the link: https://imagemagick.org/script/escape.php

If you want the original file name to also have the width and height data appended, then use the following command:

magick *.jpg[100x] -set filename:currentfile '%t-%wx%h' 'preview/%[filename:currentfile].jpg'

This command uses %w (width) and %h (height).

If you want the image size to be reduced only if it exceeds the specified size, then add a “>” symbol to the selected size:

magick '*.jpg[1000x>]' -set filename:currentfile '%t-%wx%h' 'preview/%[filename:currentfile].jpg'

For more examples of specifying the size of images, see the Image Geometry section.

Compressing images without resizing them

Besides changing the number of pixels in an image, a good result of reducing the size that a photograph occupies without much loss in quality is a decrease in the level of quality, in fact, the level of compression.

To do this, use the -quality option already discussed, after which specify a number in the range from 0 (worst quality) to 100 (best quality, minimum compression).

For details, see the section: How to check the quality level of a JPG

In the following example, all JPEG files will be compressed with quality 40 and stored in the “compressed” folder with the same names:

mkdir compressed
magick *.jpg -quality 40 -set filename:currentfile '%t' 'compressed/%[filename:currentfile].jpg'

How to prevent saving all pictures in one file

The JPEG and PNG formats do not support multi-image files, so this problem does not occur when converting to these formats. But a number of formats, such as GIF, MIFF, TIFF, PDF, MNG, HEIF, and HEIC, support multiple image files. In this case, all images will be saved to one file by default.

See also: How to enable saving photos in HEIC (HEIF) format in Android and whether it should be done

To save each image to a separate file, add the +adjoin option to your command, like so:

magick '*.jpg[1000x>]' -set filename:currentfile '%t-%wx%h' +adjoin 'heif/%[filename:currentfile].heif'

 

 

 

6. How to modify images on the Linux command line

ImageMagick is a powerful program and library for creating and modifying images on the command line. This section will cover the commands and options that you can use to imitate a drawing with paints, pencil, charcoal, make an image black and white; rotate the image to an arbitrary angle or display the image horizontally or vertically; resize the image; add or reduce noise in the image; add a frame to the image; simulate 3D; add text with custom style and formatting; superimpose one image on another; apply other popular filters.

These examples are among the simplest cases of using ImageMagick on the command line to modify images, since most of them only require one option. More complex examples will be covered in the sections on creating new images and using ImageMagick scripts.

The following image will be taken as the source:

Combining ImageMagick options and actions

One ImageMagick (magick) command can perform several actions at once. Moreover, if you use formats like JPEG, that is, those that compress images with loss of quality (lossy), then try to reduce the number of operations (the number of times JPG is compressed) and do all the actions at once (or use formats that save lossless images (e.g. PNG).

Most of the options discussed below can be combined with each other, as well as with the familiar -scale PIXELS and -quality QUALITY options.

For example:

magick IMAGE.jpg -scale 200 -paint 1 test.jpg

You can also combine the already considered image conversion with any options. That is, in one command you can modify the image and convert it to another format:

magick IMAGE.jpg -scale 200 -paint 1 test.png

How to extract an area of an image (cropping a picture)

To extract a region of an image use the option -extract WIDTHxHEIGHT+x0+y0

In this line:

  • WIDTH – the width of the area to be extracted
  • HEIGHT – the height of the area to be extracted
  • x0 – x coordinate of the upper left corner of the area to be extracted
  • y0 – y coordinate of the upper left corner of the area to be extracted

The -extract option must come before the image from which the region is being extracted!

After using this option (after the name of the file from which the region is extracted), specify the +repage option, which will override this option, otherwise it will be applied to all images processed in this command.

The following command extracts a 500×400 pixel area from the IMAGE.jpg file, which is located at a distance of 300 pixels from the left edge and 150 pixels from the top edge, and saves the resulting new image to the test21.jpg file:

magick -extract 500x400+300+150 IMAGE.jpg +repage test21.jpg

Instead of the -extract WIDTHxHEIGHT+x0+y0 option, you can use the format:

FILE[WIDTHxHEIGHT+x0+y0]

The following command is identical to the previous one:

magick 'IMAGE.jpg[500x400+300+150]' +repage test21.jpg

When processing a large number of photos, to save computer resources (primarily RAM), use Image cropping while reading.

How to apply an effect to an area of an image

By default, the options shown below change the entire image. If you want to change only a certain area of the image, then use the option -region WIDTHxHEIGHT+x0+y0

In this line:

  • WIDTH – the width of the area being modified
  • HEIGHT – the height of the area being modified
  • x0 – x coordinate of the upper left corner of the area being modified
  • y0 – y coordinate of the upper left corner of the area being modified

For example, in the following command, the -negate effect (see the description of this option below) will be applied only to the 500×400 pixel area of the IMAGE.jpg image, which is located at a distance of 300 pixels from the left edge and 150 pixels from the top edge, the resulting new image is saved in test21.jpg file:

magick IMAGE.jpg -region 500x400+300+150 -negate test21.jpg

How to imitate an oil painting

To make the photo look like a painting, use the -paint RADIUS option.

This option creates an imitation of an oil painting.

Each pixel is replaced by the most frequently occurring color in a circular neighborhood whose width is determined by the radius.

Command example:

magick IMAGE.jpg -paint 4 test1.jpg

Result:

How to imitate a charcoal drawing

To make the photo look like it was drawn with charcoal, use the -charcoal RADIUS option.

Command example:

magick IMAGE.jpg -charcoal 5 test2.jpg

Result:

How to mimic a pencil sketch

The -sketch GEOMETRY option creates a simulated pencil sketch.

Command example:

magick IMAGE.jpg -sketch 5 test3.jpg

Result:

This option has the following syntax options:

  • -sketch radius
  • -sketch radius{xsigma}+angle

The last version of the option creates a sketch with the specified radius, standard deviation (sigma) and angle. The specified angle is the angle at which the image is drawn. This is the direction people think the object is coming from.

How to make an image black and white

How to convert an image to black and white on the Linux command line? With the -monochrome option, you can convert an image to black and white.

Command example:

magick IMAGE.jpg -monochrome test4.jpg

Result:

How to create an image negative

With the -negate option, you can replace each pixel with its complementary color.

The red, green, and blue intensity of the image is inverted. White becomes black, yellow becomes blue, and so on. Use +negate to invert only the pixels in a grayscale image.

Command example:

magick IMAGE.jpg -negate test5.jpg

Result:

How to flip and flop images (vertical and horizontal image mirroring) on the Linux command line

To flip and flop an image horizontally or vertically, use the options:

  • -flip (image will be flipped upside down)
  • -flop (the image will be flopped, mirrored from left to right - just like in a mirror)

Command example:

magick IMAGE.jpg -flip test6.jpg

Result:

Command example:

magick IMAGE.jpg -flop test7.jpg

Result:

How to rotate an image on the Linux command line

To rotate an image, use the -rotate DEGREES option. Degrees can be set to either positive (for clockwise rotation) or negative (for counterclockwise rotation) values. For example:

magick IMAGE.jpg -rotate 30 test8.jpg
magick IMAGE.jpg -rotate -30 test8.jpg

By default, the empty corners that appear will be filled with white, if you want to change the color, then use the -background option:

magick IMAGE.jpg -background VioletRed -rotate 30 test8.jpg

You can see the names of all colors with the following command:

magick -list color

See also:

If you want to rotate the image and fill the empty corners with stretched bands of color around the edges of the image, then use the -distort ScaleRotateTranslate ANGLE option, for example:

magick IMAGE.jpg -distort ScaleRotateTranslate 30 test9.jpg

If you want to have the image scaled up to fill the entire space instead of filling empty edges, then use the -distort ScaleRotateTranslate SCALE,ANGLE option, for example:

magick IMAGE.jpg -distort ScaleRotateTranslate 1.5,30 test10.jpg

The -distort ScaleRotateTranslate option can take a different number of arguments, which also change its behavior:

magick IMAGE.jpg -distort ScaleRotateTranslate 500,500,30 test10.jpg

See the -distort option help for details: https://imagemagick.org/script/command-line-options.php#distort

Two more options related to rotating and flipping images:

  • -transpose: will flip the image diagonally from top left to bottom right. This option mathematically transposes an array of pixels. It is equivalent to the “-flip -rotate 90” option sequence.
  • -transverse: Flips the image diagonally from the bottom left image to the top right. Equivalent to “-flop -rotate 90”.

Examples of using:

magick IMAGE.jpg -transpose test11.jpg
magick IMAGE.jpg -transverse test11.jpg

Rolling images. Film effect

The -roll GEOMETRY option rotates the image vertically or horizontally so that its parts are on the opposite side. As an argument to the -roll option, you need to specify two numbers, which can be both positive and negative, which indicate the number of pixels by which you want to rotate the image vertically and horizontally.

Command example:

magick IMAGE.jpg -roll +130+150 test11.jpg

Result:

How to simulate a Polaroid photo on the command line

With the -polaroid ANGLE option, you can simulate a Polaroid photo.

Angle indicates how much the image should be rotated.

Command example:

magick IMAGE.jpg -polaroid -10 test12.jpg

Result:

How to reduce image noise on the Linux command line

The -noise GEOMETRY option does not work in recent versions of ImageMagick because it has been deprecated. Use -statistic NonPeak INTENSITY instead.

For example:

magick IMAGE.jpg -statistic NonPeak 3 test13.jpg

Too high INTENSITY values make the image unrealistic.

How to increase image noise on the Linux command line

To increase noise, use the following set of options: -attenuate INTENSITY +noise TYPE

For INTENSITY, enter a number (default 1.0). For Noise TYPE, select from the following options:

  • Gaussian
  • Impulse
  • Laplacian
  • Multiplicative
  • Poisson
  • Random
  • Uniform

Note that Random will replace the image with noise, not add noise to the image. Use Uniform if you want to add random noise to an image.

Command example:

magick IMAGE.jpg -attenuate 1.5 +noise Gaussian test14.jpg

Result:

You can achieve the same result with the -evaluate option, for example:

magick IMAGE.jpg -evaluate Gaussian-noise 1.5 test14.jpg

Detailed description of the -evaluate option and its possible arguments: https://imagemagick.org/script/command-line-options.php#evaluate

How to lighten or darken the edges of an image

The -raise VALUE option will lighten or darken the edges of the image to create a 3D effect.

This will create a 3D effect. Use -raise to create a raised effect, otherwise use +raise.

magick IMAGE.jpg -raise 50 test22.jpg
magick IMAGE.jpg +raise 50 test22.jpg

Unlike the similar -frame option (discussed below), -raise does not resize the image.

How to create a border around an image

To frame an image, use the -frame option.

If you want a single-color frame without effects, then specify a single number after -frame:

magick IMAGE.jpg -mattecolor peru -frame 19 test23.jpg

If you want a frame with a 3D effect, then specify four numbers: -frame AxA+B+C:

magick IMAGE.jpg -mattecolor peru -frame 19x19+3+6 test23.jpg

The first two numbers (A) determine the thickness of the frame, the second number (B) determines the thickness of the outer edge, the last number (C) determines the thickness of the inner edge.

The -mattecolor option sets the border color.

You can see the names of all colors with the following command:

magick -list color

See also:

How to create a vignette

The -vignette option softens the edges of the image in a vignette style.

Format: -vignette RADIUS{xSIGMA}{+-}x{+-}y{%}

The falloff of the vignette effect is controlled by RADIUSxSIGMA (there are two variables, radius and sigma, and the multiplication sign, i.e. radius x sigma). For nominal rolloff, this would be set to 0xsigma. A value of 0x0 will produce a circle/ellipse with no rolloff. The arguments x and y control the size of the circle. Larger values decrease the radii and smaller values increase the radii. Values of +0+0 will generate a circle/ellipse the same size as the image. The default values for x and y are 10% of the corresponding image dimension. Thus, the radii will be decreased by 10%, i.e., the diameters of the circle/ellipse will be 80% of the corresponding image dimension. Note, the percent symbol in a geometry affects x and y, whereas radius and sigma are absolute (e.g., -vignette "0x2+10%+10%").

Command examples:

magick IMAGE.jpg -vignette 20x100 test24.jpg
magick IMAGE.jpg -vignette 0x100 test24.jpg

Result of the last command:

Many examples of how to make various frames and frames for images can be found at the link: https://imagemagick.org/Usage/thumbnails/

How to lighten an image. How to increase exposure

To increase the amount of white, use the -sigmoidal-contrast NUMBER,0% option. The larger the NUMBER, the stronger the change will be, for example:

magick IMAGE.jpg -sigmoidal-contrast 4,0% test25.jpg

To reduce the amount of black, use the +sigmoidal-contrast NUMBER,100% option. The larger the NUMBER, the stronger the change will be, for example:

magick IMAGE.jpg +sigmoidal-contrast 4,100% test25.jpg

How to make an image darker. How to reduce exposure

To reduce the amount of white, use the +sigmoidal-contrast NUMBER,0% option. The larger the NUMBER, the stronger the change will be, for example:

magick IMAGE.jpg +sigmoidal-contrast 4,0% test26.jpg

To increase the amount of black, use the -sigmoidal-contrast NUMBER,100% option. The larger the NUMBER, the stronger the change will be, for example:

magick IMAGE.jpg -sigmoidal-contrast 4,100% test26.jpg

7. How to composite and append images on the Linux command line (merge images)

How to put one image on top of another

Let’s consider how to overlay an image on an image and merge images.

The command to overlay one image on another consists of three main parts:

  1. The name of the initial image that will act as the background.
  2. The name of the second image to overlay the first. Geometry options, as well as the “-composite” option. This item can be repeated many times to overlay several images on one.
  3. The name of the output file.

In the following example, IMAGE.jpg will be overlaid with IMAGE1.jpg, whose width will be 400 pixels, this image will be shifted from the left edge by 50 pixels and from the top by 10 pixels, the new image will be saved to the test27.jpg file:

magick IMAGE.jpg IMAGE1.jpg -geometry 400x300+50+10 -composite test27.jpg

Please note that the overlay image will have a width of 400 pixels, and the height will be adjusted automatically to maintain the original proportions of the image, see the Image Geometry section for details.

If you want to place the image in the center, in one of the corners, or in the middle of one of the sides, then instead of specifying an offset, you can use the -gravity option.

With the -gravity option you can change the origin, for example:

magick IMAGE.jpg IMAGE1.jpg -gravity North -geometry 400x300+0+0 -composite test27.jpg
magick IMAGE.jpg IMAGE1.jpg -gravity South -geometry 400x300+0+0 -composite test27.jpg
magick IMAGE.jpg IMAGE1.jpg -gravity SouthWest -geometry 400x300+0+0 -composite test27.jpg

See also The -gravity option defines the origin for the Offset.

A similar command, in which images from IMAGE1.jpg to IMAGE6.jpg are superimposed on the IMAGE.jpg image:

magick IMAGE.jpg IMAGE1.jpg -geometry 400x300+50+10 -composite IMAGE2.jpg -geometry 330x230+225+210 -composite IMAGE3.jpg -geometry 350x300+475+260 -composite IMAGE4.jpg -geometry 400x300+25+410 -composite IMAGE5.jpg -geometry 400x300+625+10 -composite IMAGE6.jpg -geometry 350x300+600+450 -composite test28.jpg

Note that the -composite option is applied after each image!

To better understand the logic, brackets have been added to the previous command that combine the image and its settings, this command does not differ from the previous one in its result:

magick IMAGE.jpg \( IMAGE1.jpg -geometry 400x300+50+10 \) -composite \( IMAGE2.jpg -geometry 330x230+225+210 \) -composite \( IMAGE3.jpg -geometry 350x300+475+260 \) -composite \( IMAGE4.jpg -geometry 400x300+25+410 \) -composite \( IMAGE5.jpg -geometry 400x300+625+10 \) -composite \( IMAGE6.jpg -geometry 350x300+600+450 \) -composite b.jpg

Since the height is selected automatically, it can be omitted:

magick IMAGE.jpg IMAGE1.jpg -geometry 400x+50+10 -composite IMAGE2.jpg -geometry 330x+225+210 -composite IMAGE3.jpg -geometry 350x+475+260 -composite IMAGE4.jpg -geometry 400x+25+410 -composite IMAGE5.jpg -geometry 400x+625+10 -composite IMAGE6.jpg -geometry 350x+600+450 -composite b.jpg

As a background, instead of a photo, you can specify the background color, for this use the -size SIZE canvas:COLOR set of options. For example, the following command overlays images on a 1000×750 red background:

magick -size 1000x750 canvas:red IMAGE1.jpg -geometry 400x300+50+10 -composite IMAGE2.jpg -geometry 330x230+225+210 -composite IMAGE3.jpg -geometry 350x300+475+260 -composite IMAGE4.jpg -geometry 400x300+25+410 -composite IMAGE5.jpg -geometry 400x300+625+10 -composite IMAGE6.jpg -geometry 350x300+600+450 -composite test29.jpg

How to append photos without overlay

The -append option connects the current images vertically or horizontally with +append.

This option creates one longer image by concatenating all current images in sequence from top to bottom.

magick IMAGE.jpg IMAGE1.jpg -append test31.jpg

Use +append to add images from left to right.

magick IMAGE.jpg IMAGE1.jpg +append test31.jpg

If they have different widths, the narrower images are padded with the current background color setting, and their position relative to each other can be controlled by the current -gravity setting.

See also The -gravity option defines the origin for the Offset.

The background color can be set with the -background COLOR option. For example:

magick IMAGE.jpg -background Violet IMAGE1.jpg -append test30.jpg

You can also use the -scale option to scale images to the same size:

magick IMAGE.jpg -scale 1000 IMAGE1.jpg -scale 1000 -append test30.jpg

The previous command will bring both images to a width of 1000px and stack them on top of each other.

A similar command, but instead of placing the images on top of each other, it will place them from left to right (horizontally):

magick IMAGE.jpg -scale 1000 IMAGE1.jpg -scale 1000 +append test30.jpg

How to append photos with space between them

For more flexible options, including the ability to add space between images, use -smush.

The -smush OFFSET option adds a sequence of images together, ignoring transparency.

-smush is a more flexible version of -append, joining images in sequence from top to bottom (-smush) or left to right (+smush) with spacing between images according to the specified offset.

If the offset is negative, the images will overlap by that amount.

-smush respects -gravity. Any empty space will be filled with the background color.

For zero offset images and transparent images, the opaque parts of the two images will be aligned as closely as possible without overlapping.

An example of a command with the -smush option (brings images to the same width of 1000 pixels and places them on top of each other, separated by a space of 100 pixels):

magick IMAGE.jpg -scale 1000 -background Violet IMAGE1.jpg -scale 1000 -smush 100 test31.jpg

 

 

 

8. How to create and convert animated GIF and video files

 

9. How to create images with ImageMagick on the command line

 

10. How to add text to images in ImageMagick

How to put text on image in ImageMagick

Text output in ImageMagick, on the one hand, is very flexible and allows you to configure any text parameters, but on the other hand, because of this flexibility, it is somewhat confusing, since there are a large number of options for setting text.

Adding a caption to ImageMagick is possible with:

  • label: – is an image type intended for creating files representing labels or for adding labels to images
  • caption: – is another type of image that differs from label: in that instead of increasing the text size to the specified “-size” parameter, it wraps any long lines that do not fit into the specified “-size” width. That is, long text is split into lines.
  • text: – is another type of image, the purpose of which is to convert large texts into a graphic format.
  • -draw – is an option that gives the command to draw one or another graphical primitive. Text is also present among graphic primitives. Currently, as a text output, it has somewhat lost its relevance due to the addition of the following option.
  • -annotate – is another option designed to conveniently add text to an image. This option uses -draw, and is intended by the author of the program as a easier and more powerful alternative to this option.

In addition to the named options, you can also note the options that are primarily responsible for metadata, but sometimes their value is also displayed along with the picture:

  • -label
  • -comment
  • -caption

What to use to display text on images in ImageMagick – label:, caption: or -annotate?

To add an inscription to the image in the choice between “-annotate” and “-draw”, we will use the advice of the author of the program and we will use “-annotate”.

As far as “label:” and “caption:” are concerned, these images also have some advantages. For example, “caption:” can distribute long text into lines so that it fits in a certain area. And “label:” knows how to select the font size so that it fits best into the given size.

But with all its capabilities, “label:” and “caption:” are still images, so when you add text to them, it has a background. However, if desired, the background can be made transparent.

The “-annotate” option can also output text with the specified background color, but by default it only outputs text without any background.

All three variants (“label:”, “caption:” and “-annotate”) can display multiline text, but only “caption:” can automatically span text across multiple lines.

In general, “-annotate” seems to be a more universal option when you need to add text to an image.

The “label:” and “caption:” options are best suited when you need to add a caption not on the image itself, but below or above it, or even on the image, but on the background and within the specified size. Also “label:” and “caption:” are handy when you need to create a new image consisting of a caption, such as a button for a web interface.

Options for -annotate

This section contains all the options that affect the text shown with -annotate. Further, each of the options is considered in more detail and examples of its use are given, and this section can be used as a quick reference to quickly find the desired option.

If any option related to -annotate is missing, then write about it in the comments.

  • -pointsize. Font size.
  • -font. The name of the font.
  • -family. Font family.
  • -fill. Font color.
  • -stroke. Stroke (outline) color.
  • -strokewidth. Stroke thickness.
  • -style. Style, for example, italic, oblique, normal.
  • -undercolor. Undercolor (background) color.
  • -gravity. Sets the origin.
  • -weight. The font weight that is trying to apply to the Font family.
  • -antialias. Turns anti-aliasing on and off.
  • -kerning. Distance between two letters.
  • -interword-spacing. Distance between two words.
  • -interline-spacing. The distance between two lines.
  • -stretch. Deprecated and removed.
  • -text-font. Deprecated and removed.

How to add text to an image on the Linux command line

To add text, use the -annotate {+-}tx{+-}ty TEXT option

In this line:

  • {+-}tx – horizontal offset in pixels from the center of gravity (by default, from the upper left corner)
  • {+-}ty – vertical offset in pixels from the center of gravity (by default, from the upper left corner)
  • TEXT – text to add to the image

The following command will add the inscription “zaLinux.ru” to the photo, shifting it from the left border by 20 pixels and from the top by 50 pixels:

magick IMAGE.jpg -annotate +20+50 'zaLinux.ru' test40.jpg

By default, text is black and has a very small font size. Therefore, if you do not see the text, then go to the next option.

How to change font size in ImageMagick

To change the size, use the -pointsize SIZE option.

Command example:

magick IMAGE.jpg -pointsize 72 -annotate +20+50 'zaLinux.ru' test40.jpg

How to change font color in ImageMagick

To change the font color, use the -fill COLOR option. This parameter accepts a color name, a hexadecimal color, or an RGB, RGBA, HSL, HSLA, CMYK, or CMYKA numeric specification. You can see the names of all colors in the How to specify color in ImageMagick section.

Enclose the color specification in quotation marks so that “#” or parentheses are not interpreted by your shell.

Colors can be specified in the following format (the list is not complete, see the previous link for more details):

  • -fill blue
  • -fill "#ddddff"
  • -fill "rgb(255,255,255)"

An example of a command that will write the text “zaLinux.ru” on the photo IMAGE.jpg with a size of 72 pt and the color DarkViolet, the text will be placed with an indent of 500 pixels from the left edge of the image and 450 pixels from the top edge, the file with the inscription will be saved with the name test40. jpg:

magick IMAGE.jpg -pointsize 72 -fill DarkViolet -annotate +500+450 'zaLinux.ru' test40.jpg

How to change font in ImageMagick

Use the -font FONT NAME option to select a font. This option will set the font to be used when annotating images with text or creating labels.

The command will show the full list of fonts:

magick -list font

For each font, information from several lines will be displayed, the line with the name of the font begins with “Font:”. It is this name that must be used with the -font option.

In addition to the fonts listed in the predefined list above, you can also specify a font from a specific source. For example, Arial.ttf is a TrueType font file, ps:helvetica is a PostScript font, and “x:fixed” is an X11 font.

To explicitly name a file or collection of fonts, specify the path to the font preceded by the @ character, such as @arial.ttf. You can specify the font weight index for font collections, eg @msgothic.ttc[1].

The following command adds a caption using the Utopia-Regular font:

magick IMAGE.jpg -font Utopia-Regular -pointsize 72 -fill DarkViolet -annotate +500+450 'zaLinux.ru' test41.jpg

The result of the following command

magick IMAGE.jpg -font Utopia-Regular -pointsize 72 -fill DarkViolet -annotate +500+150 'zaLinux.ru' -font Ubuntu -pointsize 72 -fill DarkViolet -annotate +500+250 'zaLinux.ru' -font Cormorant-Unicase-Bold -pointsize 72 -fill DarkViolet -annotate +500+350 'zaLinux.ru' -font Times-New-Roman -pointsize 72 -fill DarkViolet -annotate +500+450 'zaLinux.ru' -font Liberation-Serif -pointsize 72 -fill DarkViolet -annotate +500+550 'zaLinux.ru' test41.jpg

How to specify a font family

The -family FONT FAMILY option sets the font family for the text.

This setting suggests the font family that ImageMagick should try to use to render text. If a family can be found, it is used; if not, the default font is substituted (for example, “Arial”) or a family known to be similar (for example, “Courier” can be used if “System” is requested but not found). Note that the family can be a list of CSS style fonts.

If the FONT FAMILY name contains spaces, then put it in quotation marks, for example, the following command specifies the URW Gothic font-family:

magick IMAGE.jpg -family 'URW Gothic' -pointsize 72 -fill DarkViolet -annotate +500+450 'zaLinux.ru' test42.jpg

How to stroke text

With the two options -stroke STROKE COLOR and -strokewidth STROKEWIDTH, you can specify the color and thickness of the text stroke.

For example, in the following command, the text in the DarkViolet font is selected, the stroke color is black, and the stroke weight is set to 3:

magick IMAGE.jpg -stroke black -strokewidth 3 -font Times-New-Roman -pointsize 72 -fill DarkViolet -annotate +500+550 'zaLinux.ru' test43.jpg

The result of the command execution (shown strokes with a width of 1 to 5):

magick IMAGE.jpg -stroke black -strokewidth 1 -font Times-New-Roman -pointsize 72 -fill DarkViolet -annotate +650+50 'zaLinux.ru' -stroke black -strokewidth 2 -font Times-New-Roman -pointsize 72 -fill DarkViolet -annotate +650+150 'zaLinux.ru' -stroke black -strokewidth 3 -font Times-New-Roman -pointsize 72 -fill DarkViolet -annotate +650+250 'zaLinux.ru' -stroke black -strokewidth 4 -font Times-New-Roman -pointsize 72 -fill DarkViolet -annotate +650+350 'zaLinux.ru' -stroke black -strokewidth 5 -font Times-New-Roman -pointsize 72 -fill DarkViolet -annotate +650+450 'zaLinux.ru' -stroke black -strokewidth 6 -font Times-New-Roman -pointsize 72 -fill DarkViolet -annotate +650+550 'zaLinux.ru' test43.jpg

How to make a font italic or oblique

With the -style option, you can specify the font style, the following options are available:

  • Any
  • Italic
  • Normal
  • Oblique

You can display the full list of styles with the command:

magick -list style

Command result

magick IMAGE.jpg -style Any -family 'Times New Roman' -pointsize 72 -fill DarkViolet -annotate +650+150 'zaLinux.ru' -style Italic -family 'Times New Roman' -pointsize 72 -fill DarkViolet -annotate +650+250 'zaLinux.ru' -style Normal -family 'Times New Roman' -pointsize 72 -fill DarkViolet -annotate +650+350 'zaLinux.ru' -style Oblique -family 'Times New Roman' -pointsize 72 -fill DarkViolet -annotate +650+450 'zaLinux.ru' test44.jpg

How to change the text background color

To change the background, use the -undercolor COLOR option.

You can see the names of all colors in the How to specify color in ImageMagick section.

Command example:

magick IMAGE.jpg -undercolor Red -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +650+150 'zaLinux.ru' test45.jpg

How to change the origin of coordinates

In the previous commands, the coordinates were counted from the upper left corner. With the -gravity TYPE option, you can choose a different area as the origin.

The following values are available as TYPE:

  • None
  • Center
  • East
  • Forget
  • NorthEast
  • North
  • NorthWest
  • SouthEast
  • South
  • SouthWest
  • West

Result of command execution:

magick IMAGE.jpg -gravity None -pointsize 60 -fill DarkViolet -font Liberation-Serif -annotate +0+0 'None' -gravity Center -pointsize 60 -fill DarkViolet -font Liberation-Serif -annotate +0+0 'Center' -gravity East -pointsize 60 -fill DarkViolet -font Liberation-Serif -annotate +0+0 'East' -gravity Forget -pointsize 60 -fill DarkViolet -font Liberation-Serif -annotate +0+0 'Forget' -gravity NorthEast -pointsize 60 -fill DarkViolet -font Liberation-Serif -annotate +0+0 'NorthEast' -gravity North -pointsize 60 -fill DarkViolet -font Liberation-Serif -annotate +0+0 'North' -gravity NorthWest -pointsize 60 -fill DarkViolet -font Liberation-Serif -annotate +0+0 'NorthWest' -gravity SouthEast -pointsize 60 -fill DarkViolet -font Liberation-Serif -annotate +0+0 'SouthEast' -gravity South -pointsize 60 -fill DarkViolet -font Liberation-Serif -annotate +0+0 'South' -gravity SouthWest -pointsize 60 -fill DarkViolet -font Liberation-Serif -annotate +0+0 'SouthWest' -gravity West -pointsize 60 -fill DarkViolet -font Liberation-Serif -annotate +0+0 'West' test46.jpg

See also The -gravity option defines the origin for the Offset.

How to enable or disable anti-aliasing when adding labels

Using the -antialias and +antialias options, you can turn on/off the rendering of anti-aliasing pixels when drawing fonts and lines.

By default, objects (such as text, lines, polygons, etc.) are anti-aliased when drawn, so the -antialias option is used by default and does not need to be specifically specified.

Use +antialias to disable the addition of antialiasing edge pixels. This will reduce the number of colors added to the image to those that are directly drawn. That is, when drawing such objects, mixed colors are not added.

The following command has label antialiasing enabled (the -antialias option is implied by default and can be omitted):

magick IMAGE.jpg -antialias -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +650+150 'zaLinux.ru' test47.png

This command disables caption smoothing (antialiasing):

magick IMAGE.jpg +antialias -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +650+150 'zaLinux.ru' test48.png

In my tests, the +antialias option either does not work with the JPG format, or as a result of the format's lossy compression, anti-aliasing cancel is not noticeable.

The result of disabling anti-aliasing is clearly visible in a PNG photo. Differences are visible both without magnification and when the image is enlarged. Without magnification, the inscription seems unnaturally sharp. At high magnification, when anti-aliasing is turned off, you can see that there are no transition pixels.

When anti-aliasing is enabled, transitional pixels are visible, the colors of which differ both from the color of the inscription and from the background.

How to set font thickness

With the -weight option, you can specify the weight of the font that is trying to apply to the font family.

This option suggests the font weight that ImageMagick should try to apply to the selected font family. Use a positive integer or choose one of the following notations:

Thin			Same as fontWeight = 100.
ExtraLight		Same as fontWeight = 200.
Light			Same as fontWeight = 300.
Normal			Same as fontWeight = 400.
Medium			Same as fontWeight = 500.
DemiBold		Same as fontWeight = 600.
Bold			Same as fontWeight = 700.
ExtraBold		Same as fontWeight = 800.
Heavy			Same as fontWeight = 900.

You can view the full list of options for this option with the command:

magick -list weight

An example of the following command

magick IMAGE.jpg -weight 100 -family 'Ubuntu' -pointsize 72 -fill DarkViolet -annotate +500+70 'zaLinux.ru' -weight 300 -family 'Ubuntu' -pointsize 72 -fill DarkViolet -annotate +500+170 'zaLinux.ru' -weight 500 -family 'Ubuntu' -pointsize 72 -fill DarkViolet -annotate +500+270 'zaLinux.ru' -weight 700 -family 'Ubuntu' -pointsize 72 -fill DarkViolet -annotate +500+370 'zaLinux.ru' -weight 900 -family 'Ubuntu' -pointsize 72 -fill DarkViolet -annotate +500+470 'zaLinux.ru' test49.jpg

As you can understand, depending on the specified “weight”, one of the font options (Light, Normal, Semi-Bold, Bold) is selected, which is most suitable. Keep in mind that not all fonts have versions, so for some fonts the result will be the same regardless of what is specified with the -weight option.

Also, if you specify a specific font using the -font option instead of the -family option, then regardless of the -weight value, the label will always look the same, because in the case of -family, a choice is made from several fonts, and in the case of -font, one font is always used.

How to change letter spacing

With the -kerning option, you can specify the spacing between two letters.

Command execution example

magick IMAGE.jpg -kerning 5 -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +250+70 'zaLinux.ru' -kerning 10 -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +250+160 'zaLinux.ru' -kerning 15 -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +250+250 'zaLinux.ru' -kerning 20 -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +250+340 'zaLinux.ru' -kerning 25 -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +250+430 'zaLinux.ru' -kerning 30 -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +250+520 'zaLinux.ru' test50.jpg

How to change word spacing

With the -interword-spacing option you can set the spacing between two words.

Command execution example:

magick IMAGE.jpg -interword-spacing 5 -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +50+70 'zaLinux.ru and HackWare.ru' -interword-spacing 20 -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +50+160 'zaLinux.ru and HackWare.ru' -interword-spacing 35 -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +50+250 'zaLinux.ru and HackWare.ru' -interword-spacing 50 -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +50+340 'zaLinux.ru and HackWare.ru' -interword-spacing 65 -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +50+430 'zaLinux.ru and HackWare.ru' -interword-spacing 80 -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +50+520 'zaLinux.ru and HackWare.ru' test51.jpg

The value specified as the distance can be either positive or negative.

How to change line spacing

With the -interline-spacing option you can set the spacing between two lines.

The value specified as the distance can be either positive or negative.

magick IMAGE.jpg -interline-spacing -30 -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +50+70 'zaLinux.ru\nand\nHackWare.ru' -interline-spacing 50 -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +550+270 'zaLinux.ru\nand\nHackWare.ru' test52.jpg

How to add rotated and slanted text to a photo

You can make text slanted with additional arguments to the -annotate option.

The option can be applied with the following set of arguments:

  • -annotate DEGREES TEXT
  • -annotate X_DEGREESxY_DEGREES TEXT
  • -annotate X_DEGREESxY_DEGREES {+-}tx{+-}ty TEXT
  • -annotate {+-}tx{+-}ty TEXT

In these lines:

  • DEGREES – the angle of rotation of the entire text, without distortion
  • X_DEGREES – shift angle of the right edge of the text relative to the left edge of the text
  • Y_DEGREES – the angle of shift of the top edge of the text relative to the bottom edge of the text
  • {+-}tx – horizontal offset in pixels from the center of gravity (by default, from the upper left corner)
  • {+-}ty – vertical offset in pixels from the center of gravity (by default, from the upper left corner)
  • TEXT – text to add to the image

All previous examples use only one syntax: -annotate {+-}tx{+-}ty TEXT

Command execution example:

magick IMAGE.jpg -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate 0x0+25+70 '1. zaLinux.ru' -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate 0x50+125+170 '2. zaLinux.ru' -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate 50x0+225+270 '3. zaLinux.ru' -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate 50x30+425+270 '4. zaLinux.ru' -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate 50x+625+270 '5. zaLinux.ru' test53.jpg

Please note that in order for the text to turn out to be rotated, but without distortion, the degrees must be the same.

How to insert multiline text

Multiline text can be inserted in a variety of ways. ImageMagick understands the “\n” character as a newline character:

magick IMAGE.jpg -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +125+270 'zaLinux\n.\nru' test54.jpg

You can also tritely insert newline characters added to the image text:

magick IMAGE.jpg -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +125+270 'zaLinux
.
ru' test54.jpg

You can also create a file with a multi-line record in advance. If you put the @ symbol before the filename, the program will try to find and read the given file. In the following command, the caption for the photo will be added from the mytext.txt file:

magick IMAGE.jpg -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +125+270 @mytext.txt test54.jpg

To read standard input, use the @- construct.

Result of command execution:

magick IMAGE.jpg -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +125+270 'zaLinux\n.\nru' -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +425+270 'zaLinux
.
ru' -pointsize 72 -fill DarkViolet -font Liberation-Serif -annotate +725+270  @mytext.txt test54.jpg

How to use “label:” and “caption:” to add an image

Recall the essence of label: and caption:

  • label: – image type intended for creating files representing labels or for adding labels to images
  • caption: – another type of image that differs from “label:” in that instead of increasing the text size to the specified “-size” parameter, it wraps any long lines that do not fit into the specified “-size” width. That is, long text is broken into lines.

An example of creating an image with text:

magick -background lightblue -fill DarkViolet -font Utopia-Regular -pointsize 72 label:ZaLinux.ru label.png

Instead of specifying the size with the “-pointsize” option, you can specify the size of the image (width and height, or just the width) with the “-size” option:

magick -background lightblue -fill DarkViolet -font Utopia-Regular -size 300 label:ZaLinux.ru label-size.png

You can use the “-pointsize” and “-size” options at the same time, but then the size of the text and image may not match.

Any of the options discussed above can be used to set font and label properties.

label: and caption: support multiline input.

If you want to add a caption to an image using “label:” or “caption:”, then use the options from the sections:

For example, the following command will create a caption and add it to an image:

magick IMAGE.jpg \( -background lightblue -fill DarkViolet -font Utopia-Regular -size 1000 label:ZaLinux.ru \) -append test60.jpg

The following command is very similar to the previous one, with the difference that the first image is the caption, and then comes the photo, resulting in the caption being above the image:

magick \( -background lightblue -fill DarkViolet -font Utopia-Regular -size 1000 label:ZaLinux.ru \) IMAGE.jpg -append test61.jpg

You can place an image with an inscription anywhere in the photo, to do this, specify the coordinates of the image using the -geometry option:

magick IMAGE.jpg \( -background lightblue -fill DarkViolet -font Utopia-Regular -size 400 label:ZaLinux.ru \) -geometry +400+450 -composite test62.jpg

Using the -gravity option, you can place an inscription in one or another area of the image without specifying its coordinates, or change the origin of coordinates. The following command is to place the caption at the bottom of the photo:

magick IMAGE.jpg \( -background lightblue -fill DarkViolet -font Utopia-Regular -size 400 label:ZaLinux.ru \) -gravity South -geometry +0+0 -composite test63.jpg

This command places the caption in the very center of the photo:

magick IMAGE.jpg \( -background lightblue -fill DarkViolet -font Utopia-Regular -size 400 label:ZaLinux.ru \) -gravity Center -geometry +0+0 -composite test64.jpg

The -gravity option defines the origin for the Offset.

How to use “label:” or “caption:” to add a caption without a background

To add a caption without a background using “label:” or “caption:” you need to use the following options:

  • -transparent white – makes the background transparent
  • +antialias – disables anti-aliasing, otherwise the inscription will turn out with white spots

Command example:

magick IMAGE.jpg \( -size 320x100 +antialias -fill blue label:'ZaLinux.ru' -transparent white \) -composite test.jpg

Another way to make the background completely transparent is to initially specify a color with full transparency. To learn how to do this, see How to specify a color with transparency.

Command example:

magick IMAGE.jpg \( -background 'rgba(255,255,255,0)' -fill DarkViolet -font Utopia-Regular -size 400 label:ZaLinux.ru \) -gravity South -geometry +0+0 -composite test65.jpg

How to add text with transparency to a photo. How to make a translucent background for the added text

You can use partially transparent colors for:

  • adding text with transparency to a photo
  • creating a transparent background for the added inscription
  • to add a watermark to an image

In all cases, you can use the commands shown above, in order for the color to become transparent, just select the transparency level in the color properties. To learn how to do this, see How to specify a color with transparency.

An example of a command using a partially transparent color:

magick IMAGE.jpg -pointsize 72 -fill 'rgba(148,0,211,0.5)' -annotate +650+150 'zaLinux.ru' test.jpg

The following command uses text with transparency for the caption and for the background of the text:

magick IMAGE.jpg -undercolor 'rgba(148,0,211,0.1)' -pointsize 72 -fill 'rgba(0,0,128,0.5)' -font Liberation-Serif -annotate +650+450 'zaLinux.ru' test66.jpg

You can also use transparent colors with “label:” or “caption:” (for both background and caption), like so:

magick IMAGE.jpg \( -background 'rgba(148,0,211,0.1)' -fill 'rgba(0,0,128,0.5)' -font Utopia-Regular -size 400 label:ZaLinux.ru \) -geometry +400+450 -composite test.jpg

Bulk add captions to images

The above shows many examples of adding text with the ability to change all its properties using the “magick” program. But what if you need to add text to dozens or hundreds of images? This section will tell you how to do it.

Suppose there is a task to add text to all JPG files in the current directory and save them in the specified folder, while each file must be written with its original name.

First, let's note that in order not to specify each file separately, we will use “Wildcards in the file name”, that is, we will specify “*.jpg” as the input file.

As the output file, we will use “Specifying a file name pattern”.

Some “properties” must be defined in a special way in order to be used. For example, only “properties” prefixed with “filename:” can be used to change the output filename of an image.

Let's create a “withtext” directory:

mkdir withtext

The following command reads all .jpg files in the current directory one by one, adds the inscription “zaLinux.ru” to each of them, and saves the resulting images to the “withtext” directory with the same names:

magick *.jpg -stroke black -undercolor Red -strokewidth 3 -font Times-New-Roman -pointsize 72 -fill DarkViolet -annotate +650+500 'zaLinux.ru' -set filename:currentfile '%t' 'withtext/%[filename:currentfile].jpg'

To make it easier for you to understand, the OPTIONS FOR ADDING TEXT have been removed from the following template:

magick *.jpg OPTIONS FOR ADDING TEXT -set filename:currentfile '%t' 'withtext/%[filename:currentfile].jpg'

The following are used as OPTIONS FOR ADDING TEXT:

-stroke black -undercolor Red -strokewidth 3 -font Times-New-Roman -pointsize 72 -fill DarkViolet -annotate +650+500 'zaLinux.ru'

Adding text can be combined with any other operations, for example, the following command compresses all JPEG images to 1000 pixels, adds text with the specified properties, and saves the new images to the “withtext” directory:

magick *.jpg -scale 1000 -stroke black -undercolor Red -strokewidth 3 -font Times-New-Roman -pointsize 72 -fill DarkViolet -annotate +650+500 'zaLinux.ru' -set filename:currentfile '%t' 'withtext/%[filename:currentfile].jpg'

How to add a watermark to a large number of images

Section “How to add text with transparency to a photo. How to make a translucent background for the added text” shows how to add transparent text – this approach can be used to add a watermark to a large number of images.

You can also make the text stroke partially transparent (or remove it altogether). In the following example, both the stroke (black) and text (white) are both set to opacity 0.3:

magick *.jpg -scale 1000 -stroke 'rgba(0,0,0,0.3)' -strokewidth 3 -font Liberation-Serif -pointsize 72 -fill 'rgba(255,255,255,0.3)' -annotate +650+500 'zaLinux.ru' -set filename:currentfile '%t' 'withtext/%[filename:currentfile].jpg'

In the following example, text is also added to all JPEG files in the current directory, the resulting images are saved in the “withtext” directory. Text properties: font color white, opacity 0.4, background color black, opacity 0.4:

magick *.jpg -scale 1000 -undercolor 'rgba(0,0,0,0.4)' -font Liberation-Serif -pointsize 72 -fill 'rgba(255,255,255,0.4)' -annotate +650+500 'zaLinux.ru' -set filename:currentfile '%t' 'withtext/%[filename:currentfile].jpg'

How to choose the size of the text and its coordinates depending on the size of the image

ImageMagick has the ability to do mathematical calculations using various image properties. Mathematical calculations can be done in the %[fx:…] construct.

You can see the conventions for various image properties on this page: https://imagemagick.org/script/escape.php

For example, the width in the expression [fx:…] is denoted by the letter “w”, and the height by the letter “h”.

The following expression means width divided by 2:

%[fx:w/400]

And this expression means width minus 400 pixels:

%[fx:w-400]

These expressions can be substituted as coordinates for the -annotate option.

For example, the following -annotate option will add a caption to an image, indented 400px from the right side and 25px from the bottom of the image:

-annotate +%[fx:w-400]+%[fx:h-25] 'zaLinux.ru'

Full command example:

magick IMAGE.jpg -pointsize 72 -fill 'rgba(148,0,211,0.5)' -annotate +%[fx:w-400]+%[fx:h-25] 'zaLinux.ru' test.jpg

Automatic coordinate calculation can be used in web services, to automatically add watermarks to photos on websites, or to batch process many photos.

The following command is similar to the ones already discussed, it adds a label to all JPEG images in the current folder and saves them to the “withtext” directory. The peculiarity of this command is that it automatically calculates the position of the text, placing it 400 and 25 pixels from the bottom right edge:

magick *.jpg -scale 1000 -undercolor 'rgba(0,0,0,0.4)' -font Liberation-Serif -pointsize 72 -fill 'rgba(255,255,255,0.4)' -annotate +%[fx:w-400]+%[fx:h-25] 'zaLinux.ru' -set filename:currentfile '%t' 'withtext/%[filename:currentfile].jpg'

And in this command, the font size, as well as the indentation from the bottom right corner, is calculated automatically, adjusting to the width and height:

magick *.jpg -scale 1000 -undercolor 'rgba(0,0,0,0.4)' -font Liberation-Serif -pointsize %[fx:w/14] -fill 'rgba(255,255,255,0.4)' -annotate '+%[fx:w-(w/2.5)]+%[fx:h-(h/23)]' 'zaLinux.ru' -set filename:currentfile '%t' 'withtext/%[filename:currentfile].jpg'

Note that the expression for calculating the coordinates is now in quotation marks because it uses parentheses. Parentheses are needed to indicate the priority of performing mathematical operations. And the quotes are needed for the reason that the parentheses have a special meaning for the Linux shell, and in order for them to be sent directly to the “magick” utility instead of being interpreted by the shell, the entire value of the option is placed in quotes.

The following command sets the new size of the images, and there is no need to change such parameters of the inscription as the font size and coordinates of its location – they are calculated automatically based on the width and height of the image:

magick *.jpg -scale 2000 -undercolor 'rgba(0,0,0,0.4)' -font Liberation-Serif -pointsize %[fx:w/14] -fill 'rgba(255,255,255,0.4)' -annotate '+%[fx:w-(w/2.5)]+%[fx:h-(h/23)]' 'zaLinux.ru' -set filename:currentfile '%t' 'withtext/%[filename:currentfile].jpg'

In the previous commands, the final image size was specified explicitly, that is, all photos were reduced to the same size. But in fact, it is not necessary to change the size of the pictures. For example, the following command will select the appropriate font size and caption coordinates so that the caption is large and legible and does not go beyond the image – the font size and padding are selected for each photo individually depending on its width and height:

magick *.jpg -undercolor 'rgba(0,0,0,0.4)' -font Liberation-Serif -pointsize %[fx:w/14] -fill 'rgba(255,255,255,0.4)' -annotate '+%[fx:w-(w/2.5)]+%[fx:h-(h/23)]' 'zaLinux.ru' -set filename:currentfile '%t' 'withtext/%[filename:currentfile].jpg'

 

 

 

 

11. ImageMagick Scripts

 

12. Using the ImageMagick library in various programming languages

 

 

 

13. ImageMagick troubleshooting

The magick (convert) commands have many options, although in their basic use, for example, to convert from one format to another, you can do without options at all. Despite the seeming ease of using the magick (convert) utilities, when using them, I encountered a variety of errors, the cause of which was the unintuitive command syntax.

magick: no images found for operation…

Next command:

magick -motion-blur 10 IMAGE.jpg OUTPUT.jpg

will throw an error:

magick: no images found for operation `-motion-blur' at CLI arg 1 @ error/operation.c/CLIOption/5414.

The essence of the error is that no images were found for the specified operator. At the same time, as you can see, the command specifies the input image to convert (IMAGE.jpg) and the name of the output image (test.jpg).

To understand the cause of the error, let's look at the syntax of the magick command:

magick [INPUT-OPTIONS] INPUT FILE [OUTPUT-OPTIONS] OUTPUT FILE

That is, the magick utility distinguishes between “input file options” and “output file options”. Moreover, almost all options are OUTPUT-OPTIONS. The exceptions, i.e. INPUT-OPTIONS, are -antialias, -caption, -density, -define, -encoding, -font, -pointsize, -size, and -texture, as well as the options from the “Miscellaneous options” section.

That is, to fix this error, it is enough to move the option, placing it between the names of the input and output files. The following command will not throw an error:

magick IMAGE.jpg -motion-blur 10 OUTPUT.jpg

magick: missing output filename `-identify' …

The following command is supposed to display detailed information about the IMAGE.jpg file:

magick IMAGE.jpg -identify -verbose

But instead it throws an error:

magick: missing output filename `-identify' at CLI arg 3 @ error/magick-cli.c/ProcessCommandOptions/524.

The essence of the error is that the name of the output file is missing. Although the -identify and -verbose options do not imply any processing of the file, in order to fix the indicated error, you must specify the output file:

magick IMAGE.jpg -identify -verbose ANY.jpg

magick: MissingArgument …

In the following command, despite the correct placement of the option between the filenames, it produces an error:

magick IMAGE.jpg -posterize OUTPUT.jpg

Error text:

magick: MissingArgument `-posterize' at CLI arg 2 @ fatal/magick-cli.c/ProcessCommandOptions/447.

The reason for the error is that there is no argument for the option being used. To find out exactly what argument an option expects, see the help. In this case, the number of color levels is expected. The following command will run without error:

magick IMAGE.jpg -posterize 2 OUTPUT.jpg

magick: unrecognized option `-channel-extract'…

In the following command, the option is placed between the filenames, the option has an argument:

magick IMAGE.jpg -channel-extract 10 OUTPUT.jpg

But, nevertheless, the execution of the command ends with an error:

magick: unrecognized option `-channel-extract' at CLI arg 2 @ fatal/magick-cli.c/ProcessCommandOptions/428.

The essence of the error is that the option is not recognized. If the option is not recognized, then first check the spelling of it. If an option is spelled correctly but not recognized, then that option is obsolete and has been deprecated (deleted). According to my observations, the help output by the command

man magick

although it is generally up-to-date, it contains several obsolete options.

The official online help for “magick” options is on the following page: https://imagemagick.org/script/magick.php

magick: unable to read font `Candice' @ warning/annotate.c/RenderType/1005. (SOLVED)

When executing a command using the -font option, for example:

magick -background lightblue -fill blue -font Candice -pointsize 72 label:Anthony label.gif

an error may occur:

magick: unable to read font `Candice' @ warning/annotate.c/RenderType/1005.

The reason for the error is that you are trying to use a font that is not available on your system. If you specified the path to the file with fonts, then this file was not found.

To find out which fonts are present on your system, use the following option:

magick -list font

Why are all files saved to one file (SOLVED)

When executing a program that processes multiple files, you may encounter a situation where all resulting images will be saved into one single file.

The JPEG and PNG formats do not support multi-image files, so this problem does not occur when converting to these formats. But a number of formats, such as GIF, MIFF, TIFF, PDF, MNG, HEIF, and HEIC, support multiple image files. In this case, all images will be saved to one file by default.

See also: How to enable saving photos in HEIC (HEIF) format in Android and whether it should be done

For example, the following command will convert all JPEG images in the current folder to HEIF format:

magick '*.jpg[1000x>]' -set filename:currentfile '%t-%wx%h' 'heif/%[filename:currentfile].heif'

To save each image to a separate file, add the +adjoin option to your command, like so:

magick '*.jpg[1000x>]' -set filename:currentfile '%t-%wx%h' +adjoin 'heif/%[filename:currentfile].heif'

The option does not work, but no errors are shown

Consider the following command:

magick IMAGE.jpg -rotate 30 -background red test8.jpg

As planned, the image should be rotated by 30 degrees, and the empty corners that appear should be filled with red. As a result of executing the command, the image will indeed be rotated, but the corners will remain white.

To fix the error, you must specify the -background option first. The following command will work exactly as intended:

magick IMAGE.jpg -background red -rotate 30 test8.jpg

14. Reference information

All options of the magick command

Usage:

magick [input-options] input-file [output-options] output-file

Use any setting or operator as an output-option. Only a limited number of setting are input-option. They include: -antialias, -caption, -density, -define, -encoding, -font, -pointsize, -size, and -texture as well as any of the Miscellaneous options (see below).

Options:

       Image Settings:
         -adjoin              join images into a single multi-image file
         -affine matrix       affine transform matrix
         -antialias           remove pixel-aliasing
         -authenticate value  decrypt image with this password
         -background color    background color
         -bias value          add bias when convolving an image
         -black-point-compensation
                              use black point compensation
         -blue-primary point  chromaticity blue primary point
         -bordercolor color   border color
         -caption string      assign a caption to an image
         -cdl filename        color correct with a color decision list
         -colors value        preferred number of colors in the image
         -colorspace type     alternate image colorspace
         -comment string      annotate image with comment
         -compose operator    set image composite operator
         -compress type       type of pixel compression when writing the image
         -decipher filename   magick cipher pixels to plain pixels
         -define format:option
                              define one or more image format options
         -delay centiseconds  display the next image after pausing
         -density geometry    horizontal and vertical density of the image
         -depth value         image depth
         -direction type      render text right-to-left or left-to-right
         -display server      get image or font from this X server
         -dispose method      layer disposal method
         -dither method       apply error diffusion to image
         -encipher filename   magick plain pixels to cipher pixels
         -encoding type       text encoding type
         -endian type         endianness (MSB or LSB) of the image
         -family name         render text with this font family
         -fill color          color to use when filling a graphic primitive
         -filter type         use this filter when resizing an image
         -flatten             flatten a sequence of images
         -font name           render text with this font
         -format "string"     output formatted image characteristics
         -fuzz distance       colors within this distance are considered equal
         -gravity type        horizontal and vertical text placement
         -green-primary point chromaticity green primary point
         -intent type         type of rendering intent when managing the image color
         -interlace type      type of image interlacing scheme
         -interpolate method  pixel color interpolation method
         -kerning value       set the space between two letters
         -label string        assign a label to an image
         -limit type value    pixel cache resource limit
         -loop iterations     add Netscape loop extension to your GIF animation
         -mask filename       associate a mask with the image
         -matte               store matte channel if the image has one
         -mattecolor color    frame color
         -monitor             monitor progress
         -orient type         image orientation
         -origin geometry     image origin
         -page geometry       size and location of an image canvas (setting)
         -ping                efficiently determine image attributes
         -pointsize value     font point size
         -preview type        image preview type
         -quality value       JPEG/MIFF/PNG compression level
         -quiet               suppress all warning messages
         -red-primary point   chromaticity red primary point
         -regard-warnings     pay attention to warning messages
         -repage geometry     size and location of an image canvas
         -sampling-factor geometry
                              horizontal and vertical sampling factor
         -scene value         image scene number
         -seed value          seed a new sequence of pseudo-random numbers
         -size geometry       width and height of image
         -statistic type geometry
                              replace each pixel with corresponding statistic from the neighborhood
         -stretch type        render text with this font stretch
         -stroke color        graphic primitive stroke color
         -strokewidth value   graphic primitive stroke width
         -style type          render text with this font style
         -support factor      resize support: > 1.0 is blurry, < 1.0 is sharp
         -synchronize         synchronize image to storage device
         -taint               declare the image as modified
         -texture filename    name of texture to tile onto the image background
         -tile-offset geometry
                              tile offset
         -treedepth value     color tree depth
         -transparent-color color
                              transparent color
         -undercolor color    annotation bounding box color
         -units type          the units of image resolution
         -verbose             print detailed information about the image
         -view                FlashPix viewing transforms
         -virtual-pixel method
                              virtual pixel access method
         -weight type         render text with this font weight
         -white-point point   chromaticity white point

       Image Operators:
         -adaptive-blur geometry
                              adaptively blur pixels; decrease effect near edges
         -adaptive-resize geometry
                              adaptively resize image with data dependent triangulation
         -adaptive-sharpen geometry
                              adaptively sharpen pixels; increase effect near edges
         -annotate geometry text
                              annotate the image with text
         -auto-orient         automatically orient image
         -bilateral-blur geometry
                               non-linear, edge-preserving, and noise-reducing smoothing filter
         -black-threshold value
                              force all pixels below the threshold into black
         -blur geometry       reduce image noise and reduce detail levels
         -border geometry     surround image with a border of color
         -channel mask        set the image channel mask
         -charcoal radius     simulate a charcoal drawing
         -chop geometry       remove pixels from the image interior
         -clip                clip along the first path from the 8BIM profile
         -clip-mask filename  associate a clip mask with the image
         -clip-path id        clip along a named path from the 8BIM profile
         -colorize value      colorize the image with the fill color
         -color-matrix matrix apply color correction to the image
         -contrast            enhance or reduce the image contrast
         -contrast-stretch geometry
                              improve contrast by `stretching' the intensity range
         -convolve coefficients
                              apply a convolution kernel to the image
         -cycle amount        cycle the image colormap
         -despeckle           reduce the speckles within an image
         -draw string         annotate the image with a graphic primitive
         -edge radius         apply a filter to detect edges in the image
         -emboss radius       emboss an image
         -enhance             apply a digital filter to enhance a noisy image
         -equalize            perform histogram equalization to an image
         -evaluate operator value
                              evaluate an arithmetic, relational, or logical expression
         -extent geometry     set the image size
         -extract geometry    extract area from image
         -fft                 implements the discrete Fourier transform (DFT)
         -flip                flip image vertically
         -floodfill geometry color
                              floodfill the image with color
         -flop                flop image horizontally
         -frame geometry      surround image with an ornamental border
         -function name       apply a function to the image
         -gamma value         level of gamma correction
         -gaussian-blur geometry
                              reduce image noise and reduce detail levels
         -geometry geometry   preferred size or location of the image
         -identify            identify the format and characteristics of the image
         -ift                 implements the inverse discrete Fourier transform (DFT)
         -implode amount      implode image pixels about the center
         -integral            calculate the sum of values (pixel values) in the image
         -lat geometry        local adaptive thresholding
         -layers method       optimize or compare image layers
         -level value         adjust the level of image contrast
         -linear-stretch geometry
                              improve contrast by `stretching with saturation' the intensity range
         -median geometry     apply a median filter to the image
         -mode geometry       make each pixel the 'predominant color' of the neighborhood
         -modulate value      vary the brightness, saturation, and hue
         -monochrome          transform image to black and white
         -morphology method kernel
                              apply a morphology method to the image
         -motion-blur geometry
                              simulate motion blur
         -negate              replace each pixel with its complementary color
         -noise geometry      add or reduce noise in an image
         -normalize           transform image to span the full range of colors
         -opaque color        change this color to the fill color
         -ordered-dither NxN
                              add a noise pattern to the image with specific amplitudes
         -paint radius        simulate an oil painting
         -polaroid angle      simulate a Polaroid picture
         -posterize levels    reduce the image to a limited number of color levels
         -print string        interpret string and print to console
         -profile filename    add, delete, or apply an image profile
         -quantize colorspace reduce colors in this colorspace
         -radial-blur angle   radial blur the image
         -raise value         lighten/darken image edges to create a 3-D effect
         -random-threshold low,high
                              random threshold the image
         -range-threshold values
                              perform either hard or soft thresholding within some range of values in an image
         -region geometry     apply options to a portion of the image
         -render              render vector graphics
         -resample geometry   change the resolution of an image
         -resize geometry     resize the image
         -roll geometry       roll an image vertically or horizontally
         -rotate degrees      apply Paeth rotation to the image
         -sample geometry     scale image with pixel sampling
         -scale geometry      scale the image
         -segment values      segment an image
         -selective-blur geometry
                              selectively blur pixels within a contrast threshold
         -sepia-tone threshold
                              simulate a sepia-toned photo
         -set property value  set an image property
         -shade degrees       shade the image using a distant light source
         -shadow geometry     simulate an image shadow
         -sharpen geometry    sharpen the image
         -shave geometry      shave pixels from the image edges
         -shear geometry      slide one edge of the image along the X or Y axis
         -sigmoidal-contrast geometry
                              lightness rescaling using sigmoidal contrast enhancement
         -sketch geometry     simulate a pencil sketch
         -solarize threshold  negate all pixels above the threshold level
         -sort-pixels         sort each scanline in ascending order of intensity
         -splice geometry     splice the background color into the image
         -spread amount       displace image pixels by a random amount
         -strip               strip image of all profiles and comments
         -swirl degrees       swirl image pixels about the center
         -threshold value     threshold the image
         -thumbnail geometry  create a thumbnail of the image
         -tile filename       tile image when filling a graphic primitive
         -tint value          tint the image with the fill color
         -transform           affine transform image
         -transparent color   make this color transparent within the image
         -transpose           flip image vertically and rotate 90 degrees
         -transverse          flop image horizontally and rotate 270 degrees
         -trim                trim image edges
         -type type           image type
         -unique-colors       discard all but one of any pixel color
         -unsharp geometry    sharpen the image
         -vignette geometry   soften the edges of the image in vignette style
         -wave geometry       alter an image along a sine wave
         -white-threshold value
                              force all pixels above the threshold into white

       Image Channel Operators:
         -channel-extract channel-list
                               extract the channels in order
         -channel-inject channel-list
                               inject the channels in order
         -channel-swap channel,channel
                               swap the channels

       Image Sequence Operators:
         -affinity filename   transform image colors to match this set of colors
         -append              append an image sequence top to bottom (use +append for left to right)
         -clut                apply a color lookup table to the image
         -coalesce            merge a sequence of images
         -combine             combine a sequence of images
         -composite           composite image
         -crop geometry       cut out a rectangular region of the image
         -deconstruct         break down an image sequence into constituent parts
         -evaluate-sequence operator
                              evaluate an arithmetic, relational, or logical expression
         -flatten             flatten a sequence of images
         -fx expression       apply mathematical expression to an image channel(s)
         -hald-clut           apply a Hald color lookup table to the image
         -morph value         morph an image sequence
         -mosaic              create a mosaic from an image sequence
         -process arguments   process the image with a custom image filter
         -separate            separate an image channel into a grayscale image
         -smush geometry      smush an image sequence together
         -write filename      write images to this file

       Image Stack Operators:
         -clone indexes       clone an image
         -delete indexes      delete the image from the image sequence
         -duplicate count,indexes
                              duplicate an image one or more times
         -insert index        insert last image into the image sequence
         -swap indexes        swap two images in the image sequence

       Miscellaneous Options:
         -debug events        display copious debugging information
         -help                print program options
         -log format          format of debugging information
         -list type           print a list of supported option arguments
         -version             print version information

Detailed description of all options: https://imagemagick.org/script/magick.php

List of supported formats and their brief description

Legend:

  • * — built-in support for blobs
  • r — read support
  • w — write support
  • + — support for multiple images / multi-page images
Format Module Mode Description
3FR DNG r-- Hasselblad CFV/H3D39II (0.20.2-Release)
3G2 VIDEO r-- Media Container
3GP VIDEO r-- Media Container
AAI* AAI rw+ AAI Dune image
AI PDF rw- Adobe Illustrator CS2
APNG VIDEO rw+ Animated Portable Network Graphics
ART* ART rw- PFS: 1st Publisher Clip Art
ARW DNG r-- Sony Alpha Raw Image Format (0.20.2-Release)
ASHLAR* ASHLAR -w+ Image sequence laid out in continuous irregular courses
AVI VIDEO r-- Microsoft Audio/Visual Interleaved
AVIF HEIC rw+ AV1 Image File Format (1.12.0)
AVS* AVS rw+ AVS X image
BGR* BGR rw+ Raw blue, green, and red samples
BGRA* BGR rw+ Raw blue, green, red, and alpha samples
BGRO* BGR rw+ Raw blue, green, red, and opacity samples
BIE* JBIG rw- Joint Bi-level Image experts Group interchange format (2.1)
BMP* BMP rw- Microsoft Windows bitmap image
BMP2* BMP rw- Microsoft Windows bitmap image (V2)
BMP3* BMP rw- Microsoft Windows bitmap image (V3)
BRF* BRAILLE -w- BRF ASCII Braille format
CAL* CALS rw- Continuous Acquisition and Life-cycle Support Type 1
CALS* CALS rw- Continuous Acquisition and Life-cycle Support Type 1
CANVAS* XC r-- Constant image uniform color
CAPTION* CAPTION r-- Caption
CIN* CIN rw- Cineon Image File
CIP* CIP -w- Cisco IP phone image format
CLIP* CLIP rw+ Image Clip Mask
CMYK* CMYK rw+ Raw cyan, magenta, yellow, and black samples
CMYKA* CMYK rw+ Raw cyan, magenta, yellow, black, and alpha samples
CR2 DNG r-- Canon Digital Camera Raw Image Format (0.20.2-Release)
CR3 DNG r-- Canon Digital Camera Raw Image Format (0.20.2-Release)
CRW DNG r-- Canon Digital Camera Raw Image Format (0.20.2-Release)
CUBE* CUBE r-- Cube LUT
CUR* ICON rw- Microsoft icon
CUT* CUT r-- DR Halo
DATA* INLINE rw+ Base64-encoded inline images
DCM* DCM r-- Digital Imaging and Communications in Medicine image.
DICOM is used by the medical community for images like X-rays. The specification, "Digital Imaging and Communications in Medicine (DICOM)", is available at http://medical.nema.org/. In particular, see part 5 which describes the image encoding (RLE, JPEG, JPEG-LS), and supplement 61 which adds JPEG-2000 encoding.
DCR DNG r-- Kodak Digital Camera Raw Image File (0.20.2-Release)
DCRAW DNG r-- Raw Photo Decoder (dcraw) (0.20.2-Release)
DCX* PCX rw+ ZSoft IBM PC multi-page Paintbrush
DDS* DDS rw+ Microsoft DirectDraw Surface
DFONT* TTF r-- Multi-face font package (Freetype 2.12.1)
DJVU* DJVU r-- Deja vu
DNG DNG r-- Digital Negative (0.20.2-Release)
DOT DOT --- Graphviz
DPX* DPX rw- SMPTE 268M-2003 (DPX 2.0)
Digital Moving Picture Exchange Bitmap, Version 2.0.
DXT1* DDS rw+ Microsoft DirectDraw Surface
DXT5* DDS rw+ Microsoft DirectDraw Surface
EPDF PDF rw- Encapsulated Portable Document Format
EPI PS rw- Encapsulated PostScript Interchange format
EPS PS rw- Encapsulated PostScript
EPS2 PS2 -w- Level II Encapsulated PostScript
EPS3 PS3 -w+ Level III Encapsulated PostScript
EPSF PS rw- Encapsulated PostScript
EPSI PS rw- Encapsulated PostScript Interchange format
EPT EPT rw- Encapsulated PostScript with TIFF preview
EPT2 EPT rw- Encapsulated PostScript Level II with TIFF preview
EPT3 EPT rw+ Encapsulated PostScript Level III with TIFF preview
ERF DNG r-- Epson RAW Format (0.20.2-Release)
EXR EXR rw- High Dynamic-range (HDR) (OpenEXR 3.1.5)
FARBFELD* FARBFELD rw- Farbfeld
FAX* FAX rw+ Group 3 FAX
FAX machines use non-square pixels which are 1.5 times wider than they are tall but computer displays use square pixels, therefore FAX images may appear to be narrow unless they are explicitly resized using a geometry of "150×100%".
resized using a geometry of "150×100%".
FF* FARBFELD rw- Farbfeld
FILE* URL r-- Uniform Resource Locator (file://)
FITS* FITS rw- Flexible Image Transport System
FL32* FL32 rw- FilmLight
FLV VIDEO rw+ Flash Video Stream
FRACTAL* PLASMA r-- Plasma fractal image
FTP* URL r-- Uniform Resource Locator (ftp://)
FTS* FITS rw- Flexible Image Transport System
FTXT* FTXT rw- Formatted text image
G3* FAX rw- Group 3 FAX
G4* FAX rw- Group 4 FAX
GIF* GIF rw+ CompuServe graphics interchange format
GIF87* GIF rw- CompuServe graphics interchange format (version 87a)
GRADIENT* GRADIENT r-- Gradual linear passing from one shade to another
GRAY* GRAY rw+ Raw gray samples
GRAYA* GRAY rw+ Raw gray and alpha samples
GROUP4* TIFF rw- Raw CCITT Group4
GV DOT --- Graphviz
HALD* HALD r-- Identity Hald color lookup table image
HDR* HDR rw+ Radiance RGBE image format
HEIC HEIC rw+ High Efficiency Image Format (1.12.0)
HEIF HEIC rw+ High Efficiency Image Format (1.12.0)
HISTOGRAM* HISTOGRAM -w- Histogram of the image
HRZ* HRZ rw- Slow Scan TeleVision
HTM* HTML -w- Hypertext Markup Language and a client-side image map
HTML* HTML -w- Hypertext Markup Language and a client-side image map
HTTP* URL r-- Uniform Resource Locator (http://)
HTTPS* URL r-- Uniform Resource Locator (https://)
ICB* TGA rw- Truevision Targa image
ICO* ICON rw+ Microsoft icon
ICON* ICON rw- Microsoft icon
IIQ DNG r-- Phase One Raw Image Format (0.20.2-Release)
INFO INFO -w+ The image format and characteristics
INLINE* INLINE rw+ Base64-encoded inline images
IPL* IPL rw+ IPL Image Sequence
ISOBRL* BRAILLE -w- ISO/TR 11548-1 format
ISOBRL6* BRAILLE -w- ISO/TR 11548-1 format 6dot
J2C* JP2 rw- JPEG-2000 Code Stream Syntax (2.5.0)
J2K* JP2 rw- JPEG-2000 Code Stream Syntax (2.5.0)
JBG* JBIG rw+ Joint Bi-level Image experts Group interchange format (2.1)
JBIG* JBIG rw+ Joint Bi-level Image experts Group interchange format (2.1)
JNG* PNG rw- JPEG Network Graphics
JNX* JNX r-- Garmin tile format
JP2* JP2 rw- JPEG-2000 File Format Syntax (2.5.0)
JPC* JP2 rw- JPEG-2000 Code Stream Syntax (2.5.0)
JPE* JPEG rw- Joint Photographic Experts Group JFIF format (libjpeg-turbo 2.1.3)
JPEG* JPEG rw- Joint Photographic Experts Group JFIF format (libjpeg-turbo 2.1.3)
JPG* JPEG rw- Joint Photographic Experts Group JFIF format (libjpeg-turbo 2.1.3)
JPM* JP2 rw- JPEG-2000 File Format Syntax (2.5.0)
JPS* JPEG rw- Joint Photographic Experts Group JFIF format (libjpeg-turbo 2.1.3)
JPT* JP2 rw- JPEG-2000 File Format Syntax (2.5.0)
JSON JSON -w+ The image format and characteristics
JXL* JXL rw- JPEG XL (ISO/IEC 18181) (libjxl 0.6.1)
K25 DNG r-- Kodak Digital Camera Raw Image Format (0.20.2-Release)
KDC DNG r-- Kodak Digital Camera Raw Image Format (0.20.2-Release)
KERNEL* KERNEL -w- Morphology Kernel
LABEL* LABEL r-- Image label
M2V VIDEO rw+ MPEG Video Stream
M4V VIDEO rw+ Raw VIDEO-4 Video
MAC* MAC r-- MAC Paint
MAP* MAP rw- Colormap intensities and indices
MASK* MASK rw+ Image Clip Mask
MAT MAT rw+ MATLAB level 5 image format
MATTE* MATTE -w+ MATTE format
MEF DNG r-- Mamiya Raw Image File (0.20.2-Release)
MIFF* MIFF rw+ Magick Image File Format
MKV VIDEO rw+ Multimedia Container
MNG* PNG rw+ Multiple-image Network Graphics (libpng 1.6.37)
MONO* MONO rw- Raw bi-level bitmap
MOV VIDEO rw+ MPEG Video Stream
MP4 VIDEO rw+ VIDEO-4 Video Stream
MPC* MPC rw+ Magick Pixel Cache image format
MPEG VIDEO rw+ MPEG Video Stream
MPG VIDEO rw+ MPEG Video Stream
MRW DNG r-- Sony (Minolta) Raw Image File (0.20.2-Release)
MSL* MSL rw+ Magick Scripting Language
MSVG* SVG rw+ ImageMagick's own SVG internal renderer
MTV* MTV rw+ MTV Raytracing image format
MVG* MVG rw- Magick Vector Graphics
NEF DNG r-- Nikon Digital SLR Camera Raw Image File (0.20.2-Release)
NRW DNG r-- Nikon Digital SLR Camera Raw Image File (0.20.2-Release)
NULL* NULL rw- Constant image of uniform color
ORA ORA r-- OpenRaster format
ORF DNG r-- Olympus Digital Camera Raw Image File (0.20.2-Release)
OTB* OTB rw- On-the-air bitmap
OTF* TTF r-- Open Type font (Freetype 2.12.1)
PAL* UYVY rw- 16bit/pixel interleaved YUV
PALM* PALM rw+ Palm pixmap
PAM* PNM rw+ Common 2-dimensional bitmap format
PANGO* PANGO r-- Pango Markup Language (Pangocairo 1.50.8)
PATTERN* PATTERN r-- Predefined pattern
PBM* PNM rw+ Portable bitmap format (black and white)
PCD* PCD rw- Photo CD
PCDS* PCD rw- Photo CD
PCL PCL rw+ Printer Control Language
PCT* PICT rw- Apple Macintosh QuickDraw/PICT
PCX* PCX rw- ZSoft IBM PC Paintbrush
PDB* PDB rw+ Palm Database ImageViewer Format
PDF PDF rw+ Portable Document Format
PDFA PDF rw+ Portable Document Archive Format
PEF DNG r-- Pentax Electronic File (0.20.2-Release)
PES* PES r-- Embrid Embroidery Format
PFA* TTF r-- Postscript Type 1 font (ASCII) (Freetype 2.12.1)
PFB* TTF r-- Postscript Type 1 font (binary) (Freetype 2.12.1)
PFM* PNM rw+ Portable float format
PGM* PNM rw+ Portable graymap format (gray scale)
PGX* PGX rw- JPEG 2000 uncompressed format
PHM* PNM rw+ Portable half float format
PICON* XPM rw- Personal Icon
PICT* PICT rw- Apple Macintosh QuickDraw/PICT
PIX* PIX r-- Alias/Wavefront RLE image format
PJPEG* JPEG rw- Joint Photographic Experts Group JFIF format (libjpeg-turbo 2.1.3)
PLASMA* PLASMA r-- Plasma fractal image
PNG* PNG rw- Portable Network Graphics (libpng 1.6.37)
PNG00* PNG rw- PNG inheriting bit-depth, color-type from original, if possible
PNG24* PNG rw- opaque or binary transparent 24-bit RGB (zlib 1.2.12)
PNG32* PNG rw- opaque or transparent 32-bit RGBA
PNG48* PNG rw- opaque or binary transparent 48-bit RGB
PNG64* PNG rw- opaque or transparent 64-bit RGBA
PNG8* PNG rw- 8-bit indexed with optional binary transparency
PNM* PNM rw+ Portable anymap
POCKETMOD PDF rw+ Pocketmod Personal Organizer
PPM* PNM rw+ Portable pixmap format (color)
PS PS rw+ PostScript
PS2 PS2 -w+ Level II PostScript
PS3 PS3 -w+ Level III PostScript
PSB* PSD rw+ Adobe Large Document Format
PSD* PSD rw+ Adobe Photoshop bitmap
PTIF* TIFF rw+ Pyramid encoded TIFF
PWP* PWP r-- Seattle Film Works
QOI* QOI rw- Quite OK image format
RADIAL-GRADIENT* GRADIENT r-- Gradual radial passing from one shade to another
RAF DNG r-- Fuji CCD-RAW Graphic File (0.20.2-Release)
RAS* SUN rw+ SUN Rasterfile
RAW DNG r-- Raw (0.20.2-Release)
RGB* RGB rw+ Raw red, green, and blue samples
RGB565* RGB r-- Raw red, green, blue samples in 565 format
RGBA* RGB rw+ Raw red, green, blue, and alpha samples
RGBO* RGB rw+ Raw red, green, blue, and opacity samples
RGF* RGF rw- LEGO Mindstorms EV3 Robot Graphic Format (black and white)
RLA* RLA r-- Alias/Wavefront image
RLE* RLE r-- Utah Run length encoded image
RMF DNG r-- Raw Media Format (0.20.2-Release)
RSVG* SVG rw+ Librsvg SVG renderer (RSVG 2.54.4)
RW2 DNG r-- Panasonic Lumix Raw Image (0.20.2-Release)
SCR* SCR r-- ZX-Spectrum SCREEN$
SCT* SCT r-- Scitex HandShake
SFW* SFW r-- Seattle Film Works
SGI* SGI rw+ Irix RGB image
SHTML* HTML -w- Hypertext Markup Language and a client-side image map
SIX* SIXEL rw- DEC SIXEL Graphics Format
SIXEL* SIXEL rw- DEC SIXEL Graphics Format
SPARSE-COLOR* TXT -w+ Sparse Color
SR2 DNG r-- Sony Raw Format 2 (0.20.2-Release)
SRF DNG r-- Sony Raw Format (0.20.2-Release)
STEGANO* STEGANO r-- Steganographic image
STRIMG* STRIMG rw- String to image and back
SUN* SUN rw+ SUN Rasterfile
SVG* SVG rw+ Scalable Vector Graphics (RSVG 2.54.4)
SVGZ* SVG rw+ Compressed Scalable Vector Graphics (RSVG 2.54.4)
TEXT* TXT r-- Text
TGA* TGA rw- Truevision Targa image
THUMBNAIL* THUMBNAIL -w+ EXIF Profile Thumbnail
TIFF* TIFF rw+ Tagged Image File Format (LIBTIFF, Version 4.4.0)
TIFF64* TIFF rw+ Tagged Image File Format (64-bit) (LIBTIFF, Version 4.4.0)
TILE* TILE r-- Tile image with a texture
TIM* TIM r-- PSX TIM
TM2* TIM2 r-- PS2 TIM2
TTC* TTF r-- TrueType font collection (Freetype 2.12.1)
TTF* TTF r-- TrueType font (Freetype 2.12.1)
TXT* TXT rw+ Text
UBRL* BRAILLE -w- Unicode Text format
UBRL6* BRAILLE -w- Unicode Text format 6dot
UIL* UIL -w- X-Motif UIL table
UYVY* UYVY rw- 16bit/pixel interleaved YUV
VDA* TGA rw- Truevision Targa image
VICAR* VICAR rw- Video Image Communication And Retrieval
VID* VID rw+ Visual Image Directory
VIFF* VIFF rw+ Khoros Visualization image
VIPS* VIPS rw+ VIPS image
VST* TGA rw- Truevision Targa image
WBMP* WBMP rw- Wireless Bitmap (level 0) image
WEBM VIDEO rw+ Open Web Media
WEBP* WEBP rw+ WebP Image Format (libwebp 1.2.2 [020F])
WMF* WMF r-- Windows Meta File
WMV VIDEO rw+ Windows Media Video
WMZ* WMF r-- Compressed Windows Meta File
WPG* WPG r-- Word Perfect Graphics
X* X rw+ X Image
X3F DNG r-- Sigma Camera RAW Picture File (0.20.2-Release)
XBM* XBM rw- X Windows system bitmap (black and white)
XC* XC r-- Constant image uniform color
XCF* XCF r-- GIMP image
XPM* XPM rw- X Windows system pixmap (color)
XPS XPS r-- Microsoft XML Paper Specification
XV* VIFF rw+ Khoros Visualization image
XWD* XWD rw- X Windows system window dump (color)
YAML YAML -w+ The image format and characteristics
YCbCr* YCbCr rw+ Raw Y, Cb, and Cr samples
YCbCrA* YCbCr rw+ Raw Y, Cb, Cr, and alpha samples
YUV* YUV rw- CCIR 601 4:1:1 or 4:2:2

Leave Your Observation

Your email address will not be published. Required fields are marked *