memory_limit = 80M.imagecreateformjpeg()的最大图像大小是多少? [英] memory_limit=80M. what is the maximum image size for imagecreateformjpeg()?

查看:69
本文介绍了memory_limit = 80M.imagecreateformjpeg()的最大图像大小是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个虚拟主机,可提供80M的最大memory_limit(即ini_set("memory_limit","80M");).我正在使用功能为imagecreatefromjpeg()的照片上传;当我上传大图像时,它给出了错误致命错误:允许的838.08080字节的内存大小用尽"我可以限制用户的图像最大大小(以字节为单位)?还是memory_limit取决于其他因素?

i have a webhosting that gives maximum memory_limit of 80M (i.e. ini_set("memory_limit","80M");). I'm using photo upload that uses the function imagecreatefromjpeg(); When i upload large images it gives the error "Fatal error: Allowed memory size of 83886080 bytes exhausted" What maximum size (in bytes) for the image i can restrict to the users? or the memory_limit depends on some other factor?

推荐答案

8388608 的内存大小为8 MB,而不是80 MB.您可能要检查是否仍然可以在某个位置增加该值.

The memory size of 8388608 is 8 Megabytes, not 80. You may want to check whether you can still increase the value somewhere.

除此之外,图像处理的一般规则是至少需要花费

Other than that, the general rule for image manipulation is that it will take at least

image width x image height x 3 

个字节的内存以加载或创建图像.(红色为一个字节,绿色为一个字节,蓝色为一个字节,alpha透明度可能为一个字节)

bytes of memory to load or create an image. (One byte for red, one byte for green, one byte for blue, possibly one more for alpha transparency)

按照该规则,一个640 x 480像素的图像将至少需要9.2 MB的空间-不包括开销和脚本本身占用的空间.

By that rule, a 640 x 480 pixel image will need at least 9.2 Megabytes of space - not including overhead and space occupied by the script itself.

无法确定JPG文件大小的限制(以字节为单位),因为JPG是一种具有可变压缩率的压缩格式.您将需要按图像分辨率进行设置,并为此设置一个限制.

It's impossible to determine a limit on the JPG file size in bytes because JPG is a compressed format with variable compression rates. You will need to go by image resolution and set a limit on that.

如果没有足够的可用内存,则可能需要研究更有效的方法来完成所需的工作,例如平铺(一次处理图像的一部分),或者如果提供者允许,则使用

If you don't have that much memory available, you may want to look into more efficient methods of doing what you want, e.g. tiling (processing one part of an image at a time) or, if your provider allows it, using an external tool like ImageMagick (which consumes memory as well, but outside the PHP script's memory limit).

这篇关于memory_limit = 80M.imagecreateformjpeg()的最大图像大小是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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