dsj2014
2015-04-09 11:21
浏览 89
已采纳

如何在PHP中包含Imagick

I have a script to delete Exif data from image, I want to use Imagick library, I setup it with :

sudo apt-get install imagemagick
sudo apt-get install php5-imagick

then I wroth this code :

$img = new Imagick($getImage);
$img->stripImage();
$img->writeImage('new.jpg');
$img->destroy();

but I get this error:

Fatal error: Class 'ImageUploader\Imagick' not found in /opt/uploader.php on line 210

any idea please ?

图片转代码服务由CSDN问答提供 功能建议

我有一个脚本从图像中删除Exif数据,我想使用Imagick库,我设置它: / p>

  sudo apt-get install imagemagick 
sudo apt-get install php5-imagick 
   
 
 

然后我发誓这段代码 :

  $ img = new Imagick($ getImage); 
 $ img-> stripImage(); 
 $ img-> writeImage('new.jpg'  ); 
 $ img-> destroy(); 
   
 
 

但我收到此错误:

  致命错误:在第210行的/opt/uploader.php中找不到类'ImageUploader \ Imagick'
   
 
 

有什么想法吗?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dsgo31121 2015-04-09 11:36
    已采纳

    Most likely you're in a class with the namespace ImageUploader, as we can see from your error message.

    Imagick by default doesn't have a namespace, so we can instantiate the class with no namespace with a backslash (\)

    $img = new \Imagick($getImage);
    
    打赏 评论

相关推荐 更多相似问题