PHP重建映像:内存使用情况 [英] PHP rebuilding images: memory usage

查看:98
本文介绍了PHP重建映像:内存使用情况的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

致命错误 /var/www/development/example/system/libraries/Image.php 在线 130

有问题的JPEG图像没有特别大的文件大小(741 KB)。我们使用相同的代码来重建更大的图像。但是,图像的尺寸非常大(4912像素x 3264像素)。这会产生影响吗?

The JPEG image in question does not have a particularly large file size (741 KB). We've used this same code to rebuild larger images. However, the image does have unusually large dimensions (4912px x 3264px). Would this have an effect?

什么决定PHP重建图像时的内存使用量?它只是文件大小?尺寸?颜色密度?文件类型?

What determines memory usage when PHP is rebuilding an image? Is it just the file size? The dimensions? The colour density? The file type?

它破产的行是

$f1    = 'imagecreatefrom' . $tag;
$src   = $f1($file);

我认为这是足够的背景。它没有尝试重建图像。将它加载到内存中足以打破它。

I think that's enough context. It didn't get as far as trying to rebuild the image. Loading it into memory was enough to break it.

推荐答案

正如riky所说,如果可以的话,设置更高的内存限制。还要意识到尺寸比文件大小更重要(因为文件大小适用于压缩图像)。当您在GD中打开图像时,每个像素分配3-4个字节,RGB和可能的A.因此,您的4912px x 3264px图像需要使用48,098,304到64,131,072字节的内存,此外还有开销和任何其他内存脚本正在使用。

As riky said, set the memory limit higher if you can. Also realize that the dimensions are more important than the file size (as the file size is for a compressed image). When you open an image in GD, every pixel gets 3-4 bytes allocated to it, RGB and possibly A. Thus, your 4912px x 3264px image needs to use 48,098,304 to 64,131,072 bytes of memory, plus there is overhead and any other memory your script is using.

这篇关于PHP重建映像:内存使用情况的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆