Changing environmental variables

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
Posts: 5
Joined: 2012-03-21T08:12:37-07:00
Authentication code: 8675308

Changing environmental variables

Post by Falesh » 2012-05-20T16:00:43-07:00

I've got a script resizing images on a regular basis on a shared hosting account. When it is busy it hits 100% CPU usage and when that happens the pages of the site load very slowly. I would like to change it so IMagick has a lower priority then anything else, is this possible on a shared host with just cPanel/PHP? I have also looked into MAGICK_THROTTLE and MAGICK_THREAD_LIMIT and have tried to set them via setOption but they don't seem to be working as I am still getting slow page loading when the script is busy. Could you tell me if I have set them right using the following code:

Code: Select all

$client = new Zend_Http_Client('' . $video->videoId . '/0.jpg');
$imageBlob = $client->request()->getBody();
if($imageBlob == false) {
    return false;
} else {
    $thumb = new Imagick();
    $thumb->setOption('MAGICK_THREAD_LIMIT', 1);
    $thumb->setOption('MAGICK_THROTTLE', 100);
    $thumb->cropImage(480, 270, 0, 45);
    $thumb->resizeImage(194, 110, Imagick::FILTER_LANCZOS, 1);
    $thumb->setImagePage(194, 110, 0, 0);
    $thumb->writeImage('images/thumbs/' . $video->id . '.jpg');
    return true;
Many thanks!

Post Reply