我有一個96x96的圖像,我需要將它分成36個16x16,我有一個腳本,下面給出的腳本可以在我的本地主機上正常工作,但不能在我的主機上工作。將照片劃分爲X和Y部分
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和圖像魔法都是一樣不幸的是,我們沒有 他們,因爲我們有這樣的二進制文件一個PHP模塊做ImageMagick二進制和 圖像魔法路徑是/ usr/local/bin。將此功能包含在您的 腳本中,並從您的末端檢查網站功能。
我不知道如何解決這個錯誤。
我不知道,但也許一個包括與路徑的Imagick類的語句? – kjones 2012-04-25 05:29:10