ImageMagick

According to Wikipedia:

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.

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

import is part of the imagemagick package.

Running import without the 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.

Screenshot of multiple X screens

If you run twinview or dualhead, simply take the screenshot twice and use to paste them together:

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:

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=${activeWinLine:40}
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

Encryption of image data

To encrypt:

$ echo pass_phrase | magick image.jpg -encipher - -depth 8 png24:image.png

This can be decrypted by:

$ 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.

gollark: https://www.youtube.com/watch?v=7aD94Tau3RM
gollark: I see.
gollark: Is that "implement" as in "you can build a computerish thing running it" or "the individual cells will have the same behaviour they would in the actual CA, give or take the particular numbered state they're in"?
gollark: Fascinating.
gollark: Maybe I should make an option to generate the image at larger sizes and downscale it.

See also

This article is issued from Archlinux. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.