【发布时间】:2012-04-25 05:21:00
【问题描述】:
我有一个 96x96 的图像,我需要将它分成 36 个 16x16 的图像,下面给出的脚本在我的 localhost 上可以正常工作,但在我的网络主机上无法正常工作。
function makeTiles($name, $imageFileName, $crop_width, $crop_height)
{
$dir = "/pic";
$slicesDir = "/pic/16X16";
// might be good to check if $slicesDir exists etc if not create it.
$ImgExt = split(".",$imageFileName);
$inputFile = $dir . $imageFileName;
$img = new Imagick($inputFile);
$imgHeight = $img->getImageHeight();
$imgWidth = $img->getImageWidth();
$cropWidthTimes = ceil($imgWidth/$crop_width);
$cropHeightTimes = ceil($imgHeight/$crop_height);
for($i = 0; $i < $cropWidthTimes; $i++)
{
for($j = 0; $j < $cropHeightTimes; $j++)
{
$img = new Imagick($inputFile);
$x = ($i * $crop_width);
$y = ($j * $crop_height);
$img->cropImage($crop_width, $crop_height, $x, $y);
$data = $img->getImageBlob();
$newFileName = $slicesDir . $name . "_" . $x . "_" . $y . ".".$ImgExt[1];
$result = file_put_contents ($newFileName, $data);
}
}
}
遇到致命错误
Fatal error: Class 'Imagick' not found in myfile.php line number
我的主人说:
Imagick 和 image magic 都是一样的,可惜我们没有 它们作为一个 PHP 模块,我们有像 ImageMagick 二进制和 图片魔术路径是/usr/local/bin。将此功能包含在您的 编写脚本并从您的终端检查网站功能。
我不知道如何解决这个错误。
【问题讨论】:
-
我不确定,但可能是包含 Imagick 类路径的包含语句?
标签: php image fatal-error imagick