1

我需要从上传的文件(jpg、gif、png)创建拇指。我正在使用GD。

当尝试从上传的大文件(1262x16482)创建拇指时 - 我收到致命错误 致命错误:允许的内存大小为 134217728 字节用尽(试图分配 60126336 字节)

$image = imagecreatefromjpeg($file);

我试图找到关于这个问题的答案,其中大多数是关于增加 php.ini 中的 memory_limit。由于某些原因,这个解决方案不适合我。

也许有一些 php 扩展允许不是将所有文件读入内存,而只是其中的一部分。

4

2 回答 2

0

Depending on the type of file it may be mandatory to load the whole thing into memory before doing work on it.

Most graphics file formats don't store the info in a linear format. Rather the data in one section may refer to some structure in another section or vv. Your best bet would be to either up your allowed memory in php.ini or limit the file size at upload time.

于 2012-12-30T12:55:53.050 回答
0

我认为 TimThumb 的使用对你来说会更容易,因为你可能有一些错误的操作 http://code.google.com/p/timthumb/

您只需要下载它并调用图像即可。

于 2012-12-30T13:31:28.320 回答