Install ImageMagick or its php module on Ubuntu 20.04 LTS Server – H2S Media

The commands given here to install ImageMagick or PHP Imagick are applicable for both Ubuntu 18.0 LTS Bionic and Ubuntu 204.04 LTS Focal Fossa.
ImageMagick is a free, open-source software package for creating and editing raster graphics. It can currently read, modify and write more than 200 of the most popular image formats. In addition, images can be generated dynamically, which is why it is also used by web applications. it is also available as a PHP module to integrate the functionally of ImageMagick for PHP-based applications or CMS such as WordPress.
Well, if you are looking for an ImageMagick alternative the there is a program graphicsmagick, a spin-off of it, and can also be installed on Ubuntu via the default package manager.
First, run a system update command on your Ubuntu 20.04 or 18.04 server or desktop to refresh the system packages and repo cache.
Both ImageMagick main packages or its PHP module can be installed using the default system repository of Ubuntu, which means we don’t need to add any third-party repository at all.
For ImageMagick, the command will be:
Whereas those who just wanted the PHP extension, can go for:
This will select the default latest PHP version available on Ubuntu and install the available Imagick module. However, if you are looking for some specific version such as for php8.0 then you have to first add its repo and then mentioned the version in the above command.
Add PHP 8.0 repo
Run system update
And then install ImageMagick PHP extension for the 8.0 version
To check which version of this graphic program has been installed on your system, run:
(function(){for(var g="function"==typeof Object.defineProperties?Object.defineProperty:function(b,c,a){if(a.get||a.set)throw new TypeError("ES3 does not support getters and setters.");b!=Array.prototype&&b!=Object.prototype&&(b[c]=a.value)},h="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this,k=["String","prototype","repeat"],l=0;lb||1342177279>>=1)c+=c;return a};q!=p&&null!=q&&g(h,n,{configurable:!0,writable:!0,value:q});var t=this;function u(b,c){var a=b.split(“.”),d=t;a[0]in d||!d.execScript||d.execScript(“var “+a[0]);for(var e;a.length&&(e=a.shift());)a.length||void 0===c?d[e]?d=d[e]:d=d[e]={}:d[e]=c};function v(b){var c=b.length;if(0<c){for(var a=Array(c),d=0;d=c.offsetWidth&&0>=c.offsetHeight)a=!1;else{d=c.getBoundingClientRect();var f=document.body;“pageYOffset”in window?window.pageYOffset:(document.documentElement||f.parentNode||f).scrollTop);d=d.left+(“pageXOffset”in window?window.pageXOffset:(document.documentElement||f.parentNode||f).scrollLeft);f=a.toString()+”,”+d;b.b.hasOwnProperty(f)?a=!1:(b.b[f]=!0,a=a<=b.g.height&&d<=b.g.width)}a&&(b.a.push(e),b.c[e]=!0)}y.prototype.checkImageForCriticality=function(b){b.getBoundingClientRect&&z(this,b)};u("pagespeed.CriticalImages.checkImageForCriticality",function(b){x.checkImageForCriticality(b)});u("pagespeed.CriticalImages.checkCriticalImages",function(){A(x)});function A(b){b.b={};for(var c=["IMG","INPUT"],a=[],d=0;d<c.length;++d)a=a.concat(v(document.getElementsByTagName(c[d])));if(a.length&&a[0].getBoundingClientRect){for(d=0;c=a[d];++d)z(b,c);a="oh="+b.l;b.f&&(a+="&n="+b.f);if(c=!!b.a.length)for(a+="&ci="+encodeURIComponent(b.a[0]),d=1;d=a.length+e.length&&(a+=e)}b.i&&(e=”&rd=”+encodeURIComponent(JSON.stringify(B())),131072>=a.length+e.length&&(a+=e),c=!0);C=a;if(c){d=b.h;b=b.j;var f;if(window.XMLHttpRequest)f=new XMLHttpRequest;else if(window.ActiveXObject)try{f=new ActiveXObject(“Msxml2.XMLHTTP”)}catch(r){try{f=new ActiveXObject(“Microsoft.XMLHTTP”)}catch(D){}}f&&(“POST”,d+(-1==d.indexOf(“?”)?”?”:”&”)+”url=”+encodeURIComponent(b)),f.setRequestHeader(“Content-Type”,”application/x-www-form-urlencoded”),f.send(a))}}}function B(){var b={},c;c=document.getElementsByTagName(“IMG”);if(!c.length)return{};var a=c[0];if(!(“naturalWidth”in a&&”naturalHeight”in a))return{};for(var d=0;a=c[d];++d){var e=a.getAttribute(“data-pagespeed-url-hash”);e&&(!(e in b)&&0<a.width&&0<a.height&&0<a.naturalWidth&&0=b[e].o&&a.height>=b[e].m)&&(b[e]={rw:a.width,rh:a.height,ow:a.naturalWidth,oh:a.naturalHeight})}return b}var C=””;u(“pagespeed.CriticalImages.getBeaconData”,function(){return C});u(“pagespeed.CriticalImages.Run”,function(b,c,a,d,e,f){var r=new y(b,c,a,e,f);x=r;d&&w(function(){window.setTimeout(function(){A(r)},0)})});})();pagespeed.CriticalImages.Run(‘/mod_pagespeed_beacon’,’’,’Eu877fTLHi’,true,false,’YJihhRxiwDs’);
//]]>Check version of Imagemagick
Well, if you want to use this graphic program natively on your system, then ImageMagick offers 11 command-line programs, all of which access a common set of libraries, which in turn enable the writing and reading of many different files formats and extensive graphic work.
animate – plays several pictures in quick succession
convert – reads images, processes them, and saves them
compare – compares 2 images and outputs the differences as an image file
composite – superimposes several images to form one image
conjure – Runs scripts in ImageMagick’s scripting language
display – displays images on an X server
identify – outputs the file format, image size, etc. of image files
import – takes screenshots
montage – combines several images into one large single image
mogrify– like Convert, only that the input file is replaced by the output file!
stream – Reads out parts of image files and outputs them as raw data, floating-point numbers, or the like
There is a man page for each command-line program. The separate documentation can be found at/usr/share/doc/imagemagick-doc/index.html
Install PHP ImageMagick on Ubuntu 20.04 LTS Server
Other articles:
Heyan Maurya Linux
Heyan Maurya Ubuntu
Heyan Maurya Ubuntu

Heyan Maurya Linux

document.getElementById(“ak_js”).setAttribute(“value”,(new Date()).getTime());
This site uses Akismet to reduce spam. Learn how your comment data is processed.
Linux Shout crafted as a part of our main portal H2S Media to publish Linux related tutorials and open source Software.


Leave a Reply

Your email address will not be published. Required fields are marked *