私は96x96の画像を持っており、それを16x16の36個に分割する必要があります。以下に示すスクリプトは、ローカルホストでは正常に機能しますが、ウェブホストでは機能しません。
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とimagemagicはどちらも残念ながら同じですが、ImageMagickバイナリのようなバイナリを持っているPHPモジュールとしてはありません。また、Imagemagicパスは/usr / local/binです。この関数をスクリプトに含めて、Webサイトの機能を自分の側から確認してください。
このエラーを修正する方法がわかりません。