GraphicsMagick is a free open-source, modern, and powerful software suite for processing images. It was initially derived from ImageMagick, however, over the years, it has grown to be a fully independent project, with several improvements and additional features. It runs on all Unix-like operating systems such as Linux, and MacOS, and also runs on Windows.

It offers a useful and efficient assortment of tools as well as libraries that allow for reading, writing, and manipulating your images in more than 92 well-known formats (such as GIF, JPEG, JPEG-2000, PNG, PDF, PNM, and TIFF).

It can create a composite image in grid format, from multiple images, and create images in web-supported formats such as WEBP. It is also used to change image size, sharpen, color reduce, rotate, or add special effects to images of various formats. Importantly, it can create a GIF animation from multiple images and much more.

How to Install GraphicsMagick on Linux Systems

On Debian-based distributions such as Ubuntu and Linux Mint, you can install it using the apt package manager as shown.

$ sudo apt update
$ sudo apt install graphicsmagick

On Arch Linux and Fedora, you can install GraphicsMagick from the default system repositories using the package manager as shown.

$ sudo pacman -S graphicsmagick [On Arch Linux]
$ sudo dnf install GraphicsMagick [On Fedora]

On RHEL-based distributions such as CentOS Stream, Rocky Linux, and Alma Linux, you can install it from the epel repository as shown.

# dnf install epel-release
# dnf install GraphicsMagick

How to Use GraphicsMagick on Linux

To access GraphicsMagick functions, use gm – a powerful command-line utility, that offers several sub-commands such as display, animate, convert, montage, compare, identify, composite, and many more, for accessing the actual functions.

To confirm that the GraphicsMagick package has been installed on your system, you can run the following command.

$ gm display 
Verify GraphicsMagick Installation
Verify GraphicsMagick Installation

Then run the following series of commands to verify many aspects of the installed package.

$ gm convert -list formats	#check that the expected image formats are supported
$ gm convert -list fonts	#check if fonts are available
$ gm convert -list delegates	#check if delegates (external programs) are configured as expected
$ gm convert -list colors	#check if color definitions may be loaded
$ gm convert -list resources	#check that GraphicsMagick is properly identifying the resources of your machine

GraphicsMagick (gm) Command Usage in Linux

Following are some basic examples of how to use gm commands with these options.

View Image in Linux Terminal

To display or view an image from the terminal, run the following command.

$ gm display girlfriend.jpeg
View Image in Linux Terminal
View Image in Linux Terminal

Resize Image In Linux Terminal

To resize an image with a new width, specify a width and height that will auto-scale proportionally as shown.

$ gm convert -resize 300 girlfriend-1.jpeg girlfriend-1-resize-300.jpeg
$ gm display girlfriend-1-resize-300.png
Resize Image in Linux Terminal
Resize Image in Linux Terminal

You can also define a width and a height, and the command will resize the image to that dimension without altering the proportions.

$ gm convert -resize 300x150 girlfriend-1.jpeg girlfriend-1-resize-300x150.jpeg
$ gm display girlfriend-1-resize-300.png

Create Animated Image in Linux Terminal

To create an animated image of multiple images in the current working directory, you can use the following command.

$ gm animate *.png 
Animate Images in Linux Terminal
Animate Images in Linux Terminal

Note: The above-animated image quality is poor because we have optimized to lower the size of the image.

Convert Image in Linux Terminal

To convert an image from one format to another, for example .jpeg to .png and vice-versa.

$ gm convert girlfriend.jpeg girlfriend.png

You can also create a visual image directory of all your .png images as shown.

$ gm convert 'vid:*.jpeg' all_png.miff
$ gm display all_png.miff
Create Visual Image
Create Visual Image

Create Composite Image in Linux Terminal

Additionally, it is possible to create a composite image (in a grid format) from separate images as shown.

$ gm montage girlfriend.jpeg girlfriend-1.jpeg girlfriend-2.jpeg composite_image.png
$ gm display composite_image.png 
Create Grid Format Images
Create Grid Format Images

There is a lot you can do with gm command, we have just covered a few basic examples in this article. You can see all options for gm and its sub-command, for example, convert, type:

$ gm -help
$ gm help convert

For more information, visit GraphicsMagick Homepage: http://www.graphicsmagick.org/

GraphicsMagick is a powerful and feature-rich image-processing system for Linux and other Unix-like systems. If you have any questions or thoughts to share, use the feedback form below.

Similar Posts