Imagick is the extension that gives PHP the power of ImageMagick: opening formats nothing else opens, better resampling, colour profiles, turning PDFs into images. Plenty of programs require it and refuse to start without it.
|
On a shared hosting account you switch this on yourself, in the panel, with nobody’s permission. It does not arrive switched on, but it is in the extension list on Select PHP Version, with a tick box. That is the first section of this article. The WHM part further down is for people with a reseller account, a VPS or a dedicated server who need to install rather than tick.
|
On a shared account: tick it in Select PHP Version
| 1 |
In cPanel, open Select PHP Version, in the software section.
|
|
| 2 |
Note the chosen PHP version before you touch anything else. Extensions are switched on per version. Change version later and the list resets, and you have to tick it again. It is the number one cause of «it worked and then it stopped».
|
|
| 3 |
In the extension list, tick Imagick and save. The change is immediate.
|
|
| 4 |
Confirm on a PHP information page. A section with the extension’s name and the ImageMagick version has to appear. Ticking the box is not proof; the information page is. How to do it: viewing and adjusting your PHP configuration.
|
|
| 5 |
Open the site and try the feature that needed it. That is the only test that counts.
|
|
That same list holds other extensions various programs require which also arrive switched off. If you are installing a shop, a learning system or a large portal, it pays to read the program’s requirements list and tick everything at once, rather than discovering them one at a time halfway through the install.
Before that: do you really need Imagick?
GD, which is already on, covers what the overwhelming majority of sites do with images, and it uses considerably less memory. Worth asking before you switch on another moving part.
| You need |
Use |
| Resize, crop, watermark, JPEG and PNG |
GD. It is already there, and it costs less. |
| To open PDF, TIFF, PSD, EPS or SVG |
Imagick. GD reads none of those. |
| Better resampling quality, colour profiles, large batches |
Imagick. |
| A program that refuses to start without the extension |
Imagick, and there is nothing to discuss. |
And there is a third route people often miss: the ImageMagick program itself is installed on the machine, and your code can call the convert command directly, with no extension at all. The PHP functions that allow it are not disabled here: see the exec and shell_exec functions.
With WHM, a VPS or a dedicated server: installing rather than ticking
On a server of your own, or a reseller account with WHM, the server’s PHP builds are yours to assemble, and the extension is installed rather than ticked.
| 1 |
Know which PHP version you are installing into. An extension is installed per version: installing on one puts nothing on the other. Check which one the site uses.
|
|
| 2 |
In WHM, find the module installers, in the software section. There is one per PHP version, and it is where extensions from the PHP extension repository get installed.
|
|
| 3 |
Find the extension in the list and install it. It compiles, which takes a few minutes, and prints what it is doing. Read to the end: if it fails, the reason is in the last few lines.
|
|
| 4 |
Restart the web server. Without that the extension is on disk and not loaded, and you end up convinced the install failed.
|
|
| 5 |
Confirm on the PHP information page, as above.
|
|
If the install complains something is missing to compile against, what is missing is ImageMagick’s own development packages, installed through the system package manager with administrator access. On a VPS or dedicated server that is within reach; on a reseller account it is not, and the route there is to ask us.
Once it is on, the two things to watch
|
Imagick eats memory in earnest. To open an image it uncompresses the whole thing into memory. A small file on disk can take many times more once opened, and one high resolution PDF page exhausts the PHP memory limit with no warning at all: the result is a blank page. The limits, and where to change them, are in PHP limits.
|
|
If you accept images uploaded by strangers, restrict the formats. ImageMagick opens dozens of formats, and some of them, document formats especially, have been used to make servers run things they should not. Switch off in your program everything the site does not need to accept, and validate what arrives before handing it over to be opened.
|
|
Ticked the extension and the program still says it is missing? Tell us the address and the PHP version you picked.
Open a support ticket
|
RECOMMENDED PRODUCT Reseller hosting with WHM Create, host and bill your own plans, under your own brand. from £43.20/mo See plans |