Page 1 of 1

Running Imagick from alternative binary at usr/bin

Posted: 2015-08-12T05:04:11-07:00
by joakimvr
Hi guys!

I recently moved host, and I'm having some trouble running Imagick as it's installed differently from my previous host. I have attached the PHP code that worked on my old host;

From the file functions.php

Code: Select all

function thumb_create($file, $width , $height, $output) {
	try  {
	$thumb_dir = "thumb/";
	$image = $file;
        $im = new Imagick();
	$im->readImage( $image );
	$im->thumbnailImage( $width, $height );
	$im->writeImage( 'THUMB_'.$output );
	rename ('THUMB_'.$output, $thumb_dir . $output);
	return 'THUMB_'.$output;
	catch(Exception $e)
	print $e->getMessage();
	return $file;
Now, after transfering my site to Siteground I get this error;
Fatal error: Class 'Imagick' not found in /home/sitename/public_html/php/includes/functions.php on line 204
Someone from their support team told me the default imagick extension is not enabled and doesn't work on their shared servers, but I could use this alternative binary; ... agemagick/

Does anyone have any suggestions as to how I could get this code working with possibly keeping the same syntax as before in the thumb_create PHP function? I'm sure the fix is quite simple, but I can't seem to get it working, and I have little experience with server folders and binaries. Any help would be highly appriciated!

Best regards,

Re: Running Imagick from alternative binary at usr/bin

Posted: 2015-08-12T07:54:41-07:00
by Bonzo
As you already know Imagick is not installed and you have been recommended to run imagemagick from php and you will need to use exec( ). So the syntax is completely different. You can see some php Imagemagick examples following the link in my signature.

This will probably do what you want:

Code: Select all

$newFile = "thumb/".$output;
exec("convert $image -thumbnail {$width}x{$height} $newFile");