Accessing Imagick from cron job

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
roybman
Posts: 2
Joined: 2017-02-12T13:47:40-07:00
Authentication code: 1151

Accessing Imagick from cron job

Post by roybman »

I have a site running on a shared server account. I'm having an issue where I have code using imagick that works fine when initiated from a web page, but when that same code is initiated from a cron job I get a "Class 'Imagick' not found" error. I have extension="imagick.so" in the php.ini file in my account root folder, as well as in my site root folder. My hosting company spent some time looking everything over with me and cannot tell me why my cron job is unable to find imagick. I'm hoping someone here knows something about this scenario that would help.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Accessing Imagick from cron job

Post by Bonzo »

What is your cron job code?
Will any other php cron job run?
roybman
Posts: 2
Joined: 2017-02-12T13:47:40-07:00
Authentication code: 1151

Re: Accessing Imagick from cron job

Post by roybman »

I have 7 cron jobs that all run from the same folder. The only issue is the one that uses imagick.
The cron job code:

include('/home/account/folder/config.php');
include('/home/account/folder/autoload.inc.php');
$DB = DB::dbConnection();
$Themes = new Themes();
$today = date('Y-m-d');
$dateexists = $Themes->getCalItems($today);
if ($dateexists) {
$Themes->activateTheme($dateexists['ThemeKey']);
}

The activateTheme method is used from one of the web pages as well as from the cron job. It works fine from the web page.
There are several functions that execute prior to utilizing imagick and everything runs fine from the cron job up to the point that I try to create a new instance of imagick. I get the error "Class 'Imagick' not found" on this line of code:

$image = new Imagick($filepath);

But again, this runs fine from the web page and only fails from the cron job.
Post Reply