Loading...
X

magick and convert troubleshooting (ImageMagick package)

The magick (convert) utilities from the ImageMagick package are used to convert and modify images. 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.

For details on installing ImageMagick, including which dependencies need to be installed to support the maximum number of formats, see the article: ImageMagick guide: installing, using, and troubleshooting.

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.

magick: no images found for operation… (SOLVED)

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' … (SOLVED)

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 … (SOLVED)

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'… (SOLVED)

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

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

Leave Your Observation

Your email address will not be published.