Imagick在本地服务器上加载图像,而不是godaddy服务器.PHP



我有一个上传到服务器的图像,然后我获得图像信息并使用imagick调整大小,这在我的本地服务器(xammp)上很好,但当我上传到网站到godaddy时,只有特定的图像加载。以下是一段代码;

$image = frameEngine($_FILES['myFile']['tmp_name'];
$tempHeight = $image->getHeight();
$tempWidth  = $image->getWidth();
$inches     = $image->getInches();

在类frameEngine中,它读取;

Class frameEngine {
private $image;
private $height;
private $width;
private $dpi;
function __construct($file) {
   $this->image = new Imagick(realpath($file));
   $this->width = $this->image->getImageWidth();
   $this->height = $this->image->getImageHeight();
   $this->dpi = $this->image->getImageResolution();
}
public function getHeight() {
   return $this->height;
}
public function getWidth() {
   return $this->width;
}
public function getInches() {
   $dpi = $this->dpi;
   $iw = round(($this->width / $dpi['x']*100)/100,2);
   $ih = round(($this->height / $dpi['y']*100)/100,2);
   return array('w' => $iw, 'h' => $ih);    
}
}

我在getInches()中得到了一个除以零的错误,这显然是因为Imagick返回的图像高度和宽度为0,因此我认为Imagick在图像上失败了。这个图像显然很好,因为它在我的本地服务器上运行。

在得出Imagick不工作的结论之前有两件事

  1. 制作一个测试脚本并使用phpinfo()。从浏览器中点击该页面,查找该页面中提到的imagick。如果没有提到这一点,那么轰!您需要联系您的主机提供商以获取此

  2. 其次,使用老式var_dump 确保文件上传已启用并且文件上传正确

希望这对小伙子有帮助!

相关内容

最新更新