Search code examples
yii2command-line-interfaceyii2-advanced-appphp-imagine

yii2 Enable Imagine for console cron jobs


I am using a block of code

protected function generateBgThumbs($release,$promo) {

        $thumb  = ($promo->catalog_based)
                ?Yii::$app->params['promo_cover_thumb_upload_path'].DIRECTORY_SEPARATOR.'600x600_' . $release->cover_file
                :Yii::$app->params['release_thumbs_upload'].DIRECTORY_SEPARATOR.'600x600_' . $release->cover_file;
        $source = ($promo->catalog_based)
                ?Yii::$app->params['promo_cover_upload_path'] .DIRECTORY_SEPARATOR. $release->cover_file
                :Yii::$app->params['release_cover_upload'] .DIRECTORY_SEPARATOR. $release->cover_file;

        if (!file_exists($thumb)) {
            if ($release->cover_file != '' && file_exists($source)) {
                Image::getImagine()
                        ->open($source)
                        ->thumbnail(new Box(600, 600))
                        ->save($thumb, ['quality' => 90]);
            }else{
                $this->output.="Not Generated";
            }
        }
    }

to generate thumbnails for the images in my yii2 application frontend, now i have some cron jobs that i run thru Cli and when i use the same method to generate the thumbnails it gives me the following error

Your system does not support any of these drivers: gmagick,imagick,gd2

any idea if this has to do something with my cli/php.ini file? or something else, and yes i am using the statements

use yii\imagine\Image;
use Imagine\Gd;

in the top of my script file, i have Ubuntu installed.


Solution

  • i had php 7 installed for the cli mode after the last system updates i checked by typing in php -v and reverted it to php 5.7 and everything worked fine after that