我正在尝试使用 WideImage 库从 PHP 中的许多小图像中创建一个非常大的图像。
如果图像变得太大,服务器显然会耗尽内存。
无论如何,是否可以通过批量执行此过程或直接写入磁盘来解决此问题?
代码看起来像这样:
$blank = WideImage::load('../paintings/blank.png'); //this is a blank image file
$new = $blank -> resize($fullWidth,$fullHeight,'fill'); //resize to full image size
for ($x = 0; $x < $fullWidth ; $x = $x + $smallPictureWidth)
{
for ($y = 0; $y < $fullHeight ; $y = $y + $smallPictureHeight)
{
$fileName = //code to get filename based on $x and $y
$img = WideImage::load($fileName);
$new = $new -> merge($img,$x,$y,100);
}
}
$fullImageName = //code to determine file name
$new -> saveToFile($fullImageName);
谢谢!