在PHP中使用许多小图像创建大图像而不会耗尽内存

时间:2014-10-07 15:50:37

标签: php image save large-files wideimage

我正在尝试使用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);

谢谢!

0 个答案:

没有答案