{"id":12642,"date":"2019-03-28T05:47:52","date_gmt":"2019-03-28T05:47:52","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=12642"},"modified":"2019-03-28T05:47:52","modified_gmt":"2019-03-28T05:47:52","slug":"graphicsmagick-a-powerful-image-processing-cli-tool-for-linux","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/28\/graphicsmagick-a-powerful-image-processing-cli-tool-for-linux\/","title":{"rendered":"GraphicsMagick \u2013 A Powerful Image Processing CLI Tool for Linux"},"content":{"rendered":"<p><strong>GraphicsMagick<\/strong>\u00a0is a free open source, modern and powerful software suite for processing images. It was initially derived from\u00a0<a href=\"https:\/\/www.tecmint.com\/install-imagemagick-in-linux\/\" target=\"_blank\" rel=\"noopener\">ImageMagick<\/a>, however, over the years, it has grown to be a fully independent project, with a number of improvements and additional features. It runs on all Unix-like operating system such as Linux, MacOS, and also runs on Windows.<\/p>\n<p>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 88 well known formats (such as GIF, JPEG, JPEG-2000, PNG, PDF, PNM, and TIFF).<\/p>\n<p>It can create a composite image in grid format, from multiple images, and create images in web supported formats such as\u00a0<strong>WEBP<\/strong>. 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\u00a0<strong>GIF<\/strong>\u00a0animation from multiple images and much more.<\/p>\n<h3>How to Install GraphicsMagick on Linux Systems<\/h3>\n<p>On\u00a0<strong>Debian<\/strong>\u00a0and its derivative such as\u00a0<strong>Ubuntu<\/strong>\u00a0and\u00a0<strong>Linux Mint<\/strong>, you can install it using\u00a0<a href=\"https:\/\/www.tecmint.com\/apt-advanced-package-command-examples-in-ubuntu\/\" target=\"_blank\" rel=\"noopener\">APT-package manager<\/a>\u00a0as shown.<\/p>\n<pre>$ sudo apt-get update\r\n$ sudo apt-get install graphicsmagick<\/pre>\n<p>On\u00a0<strong>Arch Linux<\/strong>\u00a0and\u00a0<strong>Fedora<\/strong>, you can install\u00a0<strong>GraphicsMagick<\/strong>\u00a0from the default system repositories using package manager as shown.<\/p>\n<pre>$ sudo pacman -S graphicsmagick    [<strong>On Arch Linux<\/strong>]\r\n$ sudo dnf install GraphicsMagick  [<strong>On Fedora 25+<\/strong>]\r\n<\/pre>\n<p>On other Linux distributions such as\u00a0<strong>RHEL<\/strong>,\u00a0<strong>CentOS<\/strong>\u00a0and\u00a0<strong>Fedora<\/strong>\u00a0(older releases), you can compile\u00a0<strong>GraphicsMagick<\/strong>\u00a0from source code as shown.<\/p>\n<pre><strong>----------- Install GraphicsMagick on RHEL and CentOS -----------<\/strong> \r\n# yum install libpng libjpeg libpng-devel libjpeg-devel ghostscript libtiff libtiff-devel freetype freetype-devel jasper jasper-devel\r\n# wget -c https:\/\/downloads.sourceforge.net\/project\/graphicsmagick\/graphicsmagick\/1.3.28\/GraphicsMagick-1.3.28.tar.xz\r\n# xz -c GraphicsMagick-1.3.28.tar.xz | tar -xvf -\r\n$ cd GraphicsMagick-1.3.28\/\r\n$ .\/configure \r\n$ make\r\n$ make install\r\n<\/pre>\n<pre><strong>----------- Install GraphicsMagick on Fedora -----------<\/strong> \r\n# dnf install libpng libjpeg libpng-devel libjpeg-devel ghostscript libtiff libtiff-devel freetype freetype-devel jasper jasper-devel\r\n# wget -c https:\/\/downloads.sourceforge.net\/project\/graphicsmagick\/graphicsmagick\/1.3.28\/GraphicsMagick-1.3.28.tar.xz\r\n# xz -c GraphicsMagick-1.3.28.tar.xz | tar -xvf -\r\n$ cd GraphicsMagick-1.3.28\/\r\n$ .\/configure \r\n$ make\r\n$ make install\r\n<\/pre>\n<p>To access\u00a0<strong>GraphicsMagick<\/strong>\u00a0functions, use\u00a0<code>gm<\/code>\u00a0\u2013 a powerful command-line utility, which offers several sub-commands such as display, animate, concert, montage, compare, identify, composite and many more, for accessing the actual functions.<\/p>\n<p>To confirm that the\u00a0<strong>GraphicsMagick<\/strong>\u00a0package has been installed on your system, you can run the following command.<\/p>\n<pre>$ gm display \r\n<\/pre>\n<div id=\"attachment_28986\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/04\/Verify-GraphicsMagick-Installation.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-28986\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/04\/Verify-GraphicsMagick-Installation.png\" sizes=\"auto, (max-width: 805px) 100vw, 805px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/04\/Verify-GraphicsMagick-Installation.png 805w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/04\/Verify-GraphicsMagick-Installation-768x485.png 768w\" alt=\"Verify GraphicsMagick Installation\" width=\"805\" height=\"508\" aria-describedby=\"caption-attachment-28986\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-28986\" class=\"wp-caption-text\">Verify GraphicsMagick Installation<\/p>\n<\/div>\n<p>Then run the following series of commands to verify many aspects of the installed package.<\/p>\n<pre>$ gm convert -list formats\t#check that the expected image formats are supported\r\n$ gm convert -list fonts\t#check if fonts are available\r\n$ gm convert -list delegates\t#check if delegates (external programs) are configured as expected\r\n$ gm convert -list colors\t#check if color definitions may be loaded\r\n$ gm convert -list resources\t#check that GraphicsMagick is properly identifying the resources of your machine\r\n<\/pre>\n<h3>Learn How to Use GraphicsMagick in Linux<\/h3>\n<p>Following are some basic examples of how to use gm command with these options.<\/p>\n<p><strong>1.<\/strong>\u00a0To display or view an image from the terminal, run following command.<\/p>\n<pre>$ gm display girlfriend.jpeg\r\n<\/pre>\n<div id=\"attachment_28987\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/04\/View-Image-in-Linux-Terminal.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-28987\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/04\/View-Image-in-Linux-Terminal.png\" sizes=\"auto, (max-width: 896px) 100vw, 896px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/04\/View-Image-in-Linux-Terminal.png 896w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/04\/View-Image-in-Linux-Terminal-768x433.png 768w\" alt=\"View Image in Linux Terminal\" width=\"896\" height=\"505\" aria-describedby=\"caption-attachment-28987\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-28987\" class=\"wp-caption-text\">View Image in Linux Terminal<\/p>\n<\/div>\n<p><strong>2.<\/strong>\u00a0To resize an image with new\u00a0<strong>width<\/strong>, specify a width and height will auto scale proportionally as shown.<\/p>\n<pre>$ gm convert -resize 300 girlfriend-1.jpeg girlfriend-1-resize-300.jpeg\r\n$ gm display girlfriend-1-resize-300.png\r\n<\/pre>\n<div id=\"attachment_28989\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/04\/girlfrend-1-resize-300.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-28989\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/04\/girlfrend-1-resize-300.png\" alt=\"Resize Image in Linux Terminal\" width=\"300\" height=\"200\" aria-describedby=\"caption-attachment-28989\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-28989\" class=\"wp-caption-text\">Resize Image in Linux Terminal<\/p>\n<\/div>\n<p>You can also define a\u00a0<strong>width<\/strong>\u00a0and a\u00a0<strong>height<\/strong>, and the command will resize the image to that dimensions without altering the proportions.<\/p>\n<pre>$ gm convert -resize 300x150 girlfriend-1.jpeg girlfriend-1-resize-300x150.jpeg\r\n$ gm display girlfriend-1-resize-300.png\r\n<\/pre>\n<p><strong>3.<\/strong>\u00a0To create an animated image of multiple images in the current working directory, you can use the following command.<\/p>\n<pre>$ gm animate *.png\t\r\n<\/pre>\n<div id=\"attachment_28990\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/04\/animate-girlfriend.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-28990\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/04\/animate-girlfriend.gif\" alt=\"Animate Images in Linux Terminal\" width=\"400\" height=\"267\" aria-describedby=\"caption-attachment-28990\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-28990\" class=\"wp-caption-text\">Animate Images in Linux Terminal<\/p>\n<\/div>\n<p><strong>Note<\/strong>: The above animated image quality is poor, because we have optimized to lower the size of image.<\/p>\n<p><strong>4.<\/strong>\u00a0To convert an image to one format to other, for example\u00a0<code>.jpeg<\/code>\u00a0to\u00a0<code>.png<\/code>\u00a0and vise-versa.<\/p>\n<pre>$ gm convert girlfriend.jpeg girlfriend.png\r\n<\/pre>\n<p><strong>5.<\/strong>\u00a0Next, you can create a visual image directory of all your\u00a0<code>.png<\/code>\u00a0images as shown.<\/p>\n<pre>$ gm convert 'vid:*.jpeg' all_png.miff\r\n$ gm display all_png.miff\r\n<\/pre>\n<div id=\"attachment_28991\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/04\/Create-Visual-Image.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-28991\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/04\/Create-Visual-Image.png\" sizes=\"auto, (max-width: 903px) 100vw, 903px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/04\/Create-Visual-Image.png 903w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/04\/Create-Visual-Image-768x430.png 768w\" alt=\"Create Visual Image\" width=\"903\" height=\"505\" aria-describedby=\"caption-attachment-28991\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-28991\" class=\"wp-caption-text\">Create Visual Image<\/p>\n<\/div>\n<p><strong>6.<\/strong>\u00a0Additionally, it is possible to create a composite image (in a grid format) from separate images as shown.<\/p>\n<pre>$ gm montage girlfriend.jpeg girlfriend-1.jpeg girlfriend-2.jpeg composite_image.png\r\n$ gm display composite_image.png \r\n<\/pre>\n<div id=\"attachment_28992\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/04\/Create-Grid-Format-Images.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-28992\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/04\/Create-Grid-Format-Images.png\" alt=\"Create Grid Format Images\" width=\"384\" height=\"126\" aria-describedby=\"caption-attachment-28992\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-28992\" class=\"wp-caption-text\">Create Grid Format Images<\/p>\n<\/div>\n<p>There is a lot you can do with\u00a0<strong>gm<\/strong>\u00a0command, we have just covered a few basic examples in this article. You can see see all options for gm and its sub-command, for example, convert, type:<\/p>\n<pre>$ gm -help\r\n$ gm help convert\r\n<\/pre>\n<p>For more information, visit GraphicsMagick Homepage:\u00a0<a href=\"http:\/\/www.graphicsmagick.org\/\" target=\"_blank\" rel=\"nofollow noopener\">http:\/\/www.graphicsmagick.org\/<\/a><\/p>\n<p><strong>GraphicsMagick<\/strong>\u00a0is 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.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/graphicsmagick-image-processing-cli-tool-for-linux\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>GraphicsMagick\u00a0is a free open source, modern and powerful software suite for processing images. It was initially derived from\u00a0ImageMagick, however, over the years, it has grown to be a fully independent project, with a number of improvements and additional features. It runs on all Unix-like operating system such as Linux, MacOS, and also runs on Windows. &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/28\/graphicsmagick-a-powerful-image-processing-cli-tool-for-linux\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;GraphicsMagick \u2013 A Powerful Image Processing CLI Tool for Linux&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-12642","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12642","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=12642"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12642\/revisions"}],"predecessor-version":[{"id":12643,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12642\/revisions\/12643"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=12642"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=12642"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=12642"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}