duanmeng3573 2013-05-01 13:04
浏览 41
已采纳

如何使用Imagick运行PHP的cron作业?

I have a php script that uses imagick to get image colors among other things.

php /home/username/public_html/cron.php

I would get this error on the scheduled run

[30-Apr-2013 00:00:02] PHP Fatal error: Class 'Imagick' not found in /home/username/public_html/cron.php on line 113

A sample of the php code:

try {
      $image = new Imagick($filename);
      $image->scaleImage(1,1);
            $pixel = $image->getImagePixelColor(1, 1); 
            $color = $pixel->getColor(); 
            $image_r = $color['r'];
            $image_g = $color['g'];
            $image_b = $color['b'];

            $image->destroy();


    } catch (ImagickException $e) {
        // something went wrong, handle the problem
            $image_r = 0;
            $image_g = 0;
            $image_b = 0;


    }

Do I need set up some environmental variable so it knows where to look for imagick? It works fine if I invoke the php script from the browser. Hopefully I can move this script out of the public_html when I have it working so I don't get a third party calling it.

thanks.

  • 写回答

2条回答 默认 最新

  • dsh1956 2013-05-01 13:06
    关注

    Assuming it works in non cron environment, I notice your script is in the web root. how about using wget instead:

    wget http://localhost/cron.php
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 iOS绕地区网络检测
  • ¥15 python验证码滑块图像识别
  • ¥15 根据背景及设计要求撰写设计报告
  • ¥15 QT6颜色选择对话框显示不完整
  • ¥20 能提供一下思路或者代码吗
  • ¥15 用twincat控制!
  • ¥15 请问一下这个运行结果是怎么来的
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥15 DS18B20内部ADC模数转换器