- imagemagick(1) — Linux man page
- See Also
- ImageMagick
- Installation
- Usage
- Common operations
- Convert between image formats
- Append
- Crop, chop
- Limit the storage size
- Screenshot taking
- Screenshot of multiple X screens
- Screenshot of individual Xinerama heads
- Screenshot of the active/focused window
- Encryption of image data
- See also
- Imagemagick
- Установка
- Установка в Ubuntu (LinuxMint)
imagemagick(1) — Linux man page
ImageMagick[rg], is a software suite to create, edit, and compose bitmap images. It can read, convert and write images in a variety of formats (about 100) including GIF, JPEG, JPEG-2000, PNG, PDF, PhotoCD, TIFF, and DPX. Use ImageMagick to translate, flip, mirror, rotate, scale, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and B\[‘e]zier curves.
ImageMagick is free software delivered as a ready-to-run binary distribution or as source code that you can freely use, copy, modify, and distribute. Its license is compatible with the GPL. It runs on all major operating systems.
The functionality of ImageMagick is typically utilized from the command line or you can use the features from programs written in your favorite programming language. Choose from these interfaces: MagickCore (C), MagickWand (C), ChMagick (Ch), Magick++ (C++), JMagick (Java), L-Magick (Lisp), PascalMagick (Pascal), PerlMagick (Perl), MagickWand for PHP (PHP), PythonMagick (Python), RMagick (Ruby), or TclMagick (Tcl/TK). With a language interface, use ImageMagick to modify or create images automagically and dynamically.
ImageMagick includes a number of command-line utilities for manipulating images. Most of you are probably accustom to editing images one at a time with a graphical user interface (GUI) with such programs as gimp or Photoshop. However, a GUI is not always convenient. Suppose you want to process an image dynamically from a web script or you want to apply the same operations to many images or repeat a specific operation at different times to the same or different image. For these types of operations, the command-line image processing utility is appropriate.
In the paragraphs below, find a short description for each command-line tool.Click on the program name to get details on the program usage and a list of command-line options that alters how the program performs. If you are just getting acquianted with ImageMagick, start at the top of the list, the convert program, and work your way dowm. Also be sure to peruse Anthony Thyssen’s tutorial on how to use ImageMagick utilities to convert, compose, or edit images from the command-line. convert
convert between image formats as well as resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more. identify
describes the format and characteristics of one or more image files. mogrify
resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more. Mogrify overwrites the original image file, whereas, convert writes to a different image file. composite
overlaps one image over another. montage
create a composite image by combining several separate images. The images are tiled on the composite image optionall adorned with a border, frame, image name, and more. compare
mathematically and visually annotate the difference between an image and its reconstruction.. stream
is a lightweight tool to stream one or more pixel components of the image or portion of the image to your choice of storage formats. It writes the pixel components as they are read from the input image a row at a time making stream desirable when working with large images or when you require raw pixel components. display
displays an image or image sequence on any X server. animate
animates an image sequence on any X server. import
saves any visible window on an X server and outputs it as an image file. You can capture a single window, the entire screen, or any rectangular portion of the screen. conjure
interprets and executes scripts written in the Magick Scripting Language (MSL).
For more information about the ImageMagick, point your browser to file:///usr/share/doc/ImageMagick-6.5.4/index.html or http://www.imagemagick.org/.
See Also
convert(1), identify(1), composite(1), montage(1), compare(1), display(1), animate(1), import(1), conjure(1), quantize(5), miff(4)
ImageMagick
ImageMagick is a free and open-source software suite for displaying, converting, and editing raster image and vector image files. It can read and write over 200 image file formats.
Installation
Install the imagemagick package. Alternatively install graphicsmagick for GraphicsMagick, a fork of ImageMagick, emphasizing stability of the API and command-line interface.
Usage
See ImageMagick(1) , or gm(1) for GraphicsMagick.
- ImageMagick at /usr/share/doc/ImageMagick-7/www/index.html
- GraphicsMagick at /usr/share/doc/GraphicsMagick/www/index.html
Common operations
Note: The sign before an option is important. Opposite operations can be performed by using a plus instead of a minus.
Convert between image formats
The basic usage of this facility is to specify the existing, and desired, image formats as the filename extension. For example, to get the .jpg representation of a given .png image, use:
$ convert image.png image.jpg
Append
Combining multiple pictures into one:
$ convert -append input.pngs output.png
Crop, chop
To crop part of multiple images and convert them to another format:
$ mogrify -crop WIDTHxHEIGHT+X+Y -format jpg *.png
Where WIDTH and HEIGHT is the cropped output image size, and X and Y is the offset from the input image size.
One can also -chop to cut of a single edge from an image, using gravity to select that edge. Which is easier as less numbers, or trial and error, is involved.
$ magick frame_red.gif -gravity South -chop 0x10 chop_bottom.gif
Limit the storage size
To achieve reasonable quality for a given storage size:
$ convert image.jpg -define jpeg:extent=3000KB image_small.jpg
Hopefully, this will shorten the transmission time. Note that -quality , as in
$ convert image.jpg -quality 85% image_small.jpg
is harder to use when the correlation between quality and storage size is not clear.
Screenshot taking
An easy way to take a screenshot of your current system is using the import(1) command:
$ import -window root screenshot.jpg
Running import without the -window option allows selecting a window or an arbitrary region interactively. With -pause you can specify a delay in which you can, for example, lower some windows.
Note: If you prefer graphicsmagick alternative, just prepend «gm», e.g. $ gm import -window root screenshot.jpg .
Screenshot of multiple X screens
If you run twinview or dualhead, simply take the screenshot twice and use imagemagick to paste them together:
$ import -window root -display :0.0 -screen /tmp/0.png $ import -window root -display :0.1 -screen /tmp/1.png $ convert +append /tmp/0.png /tmp/1.png screenshot.png $ rm /tmp/.png
Screenshot of individual Xinerama heads
Xinerama-based multi-head setups have only one virtual screen. If the physical screens are different in height, you will find dead space in the screenshot. In this case, you may want to take screenshot of each physical screen individually. As long as Xinerama information is available from the X server, the following will work:
#!/bin/sh xdpyinfo -ext XINERAMA | sed '/^ head #/!d;s///' | while IFS=' :x@,' read i w h x y; do import -window root -crop $x$h+$x+$y head_$i.png done
Screenshot of the active/focused window
The following script takes a screenshot of the currently focused window. It works with EWMH/NetWM compatible X Window Managers. To avoid overwriting previous screenshots, the current date is used as the filename.
#!/bin/sh activeWinLine=$(xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)") activeWinId=$ import -window "$activeWinId" /tmp/$(date +%F_%H%M%S_%N).png
Alternatively, the following should work regardless of EWMH support:
$ import -window "$(xdotool getwindowfocus -f)" /tmp/$(date +%F_%H%M%S_%N).png
Note: If screenshots of some programs (e.g. zathura) appear blank, try appending -frame or removing -f from the xdotool command.
Encryption of image data
$ echo pass_phrase | magick image.jpg -encipher - -depth 8 png24:image.png
$ echo pass_phrase | magick image.png -decipher - image.jpg
It is highly advised to read the discussion at Encrypting Images for all sorts of issues, and suggestions, for such commands.
Metadata of image formats that have the cipher tag can be used to test for encryption. However, it could be removed or spoofed by an EXIF editing program.
$ identify -verbose image.png
In general, testing if a raster image was encrypted can be done by checking the distribution of the pixel components. If it exceeds a certain threshold, the data could be considered random and a possible candidate for encryption. However, an example for false positives are images created with the Diamond-square algorithm.
See also
- ImageMagick website for an extensive list of options, examples and showcase.
- List of applications/Multimedia#Image processing
- Fred’s ImageMagick Scripts for large collection of ImageMagic scripts
Imagemagick
Imagemagick — мощный набор консольных утилит для редактирования, создания, объединения, конвертирования графических файлов в автоматическом режиме. Поддерживает огромное количество графических форматов.
Imagemagick представляет из себя несколько утилит, запускающихся из командной строки, которые могут выполнять над графическими файлами различные действия. Его еще называют консольным графическим редактором. Очень часто Imagemagick используют в скриптах для автоматизации процесса обработки изображений, а также в графических редакторах.
Imagemagick поддерживает огромное количество графических форматов (более 200). Из популярных можно отметить форматы: JPEG, PNG, BMP, GIF, TIFF, PDF, SVG.
Возможностей у Imagemagick очень много, полный список можно получить на официальном сайте программы. Приведу только некоторые из них:
- Создание анимационных GIF файлов из группы изображений.
- Преобразование графических форматов из одного в другой.
- Преобразование цветовых палитр.
- Добавление текста произвольным шрифтом и фигур на изображение.
- Наложение изображений, одного на другое.
- Объединение группы изображений в одно.
- Добавление рамок.
- Добавление эффектов (резкость, размытие, фильтрация, маскирование и другие).
- Уменьшение или добавление шума.
- Преобразования (поворот, изменение размера, обрезка, отражение)
- Редактирование яркости, контраста, эквализация и другие операции с цветом.
В Imagemagick входит следующий набор утилит (состав может зависеть от версии):
- magick
- magick-script
- convert
- composite
- compare
- conjure
- display
- animate
- identify
- import
- montage
- mogrify
- stream
Imagemagick доступен для Linux-систем, также есть сборки для MacOS, iOS, Windows.
Установка
Установка в Ubuntu (LinuxMint)
sudo apt install imagemagick