3.7兆的图片为什么用不了imagecreatefromjpeg函数
图片上传生成缩略图,使用以下代码
$imgsrc='E:/123.jpg';
$w1 = getimagesize($imgsrc);
$src =imagecreatefromjpeg(imgsrc);// imagecreatefromjpeg($imgsrc);
$dst = ImageCreateTrueColor($x,$y);
ImageCopyResampled($dst,$src,0,0,0,0,$x,$y,$w1[0],$w1[1]);
imagejpeg($dst,$imgsrc,80);
当图片小于2M时是好用的,没问题。但是我上传了一个3.7兆的图片时,程序走到imagecreatefromjpeg时就会出现空白,后面的代码就不执行了。请问有没有什么办法解决此问题,或在上传时直接改变图片大小。
------解决方案--------------------内存不足了吧?
决定 GD 是否能够正常运行的条件,不在于图片文件的大小,而在于图片的点阵数
GD 在处理图片时会先将图片在内存中按每像素8个字节的规模展开成位图
------解决方案--------------------It's an out-of-memory issue. I don't know if there's a formula, but it seems to happen with images that are large or high-resolution. Changing the memory in php.ini might work, up to a point. After trying 768MB I gave up and use ImageMagick now.
please try use code ini_set('memory_limit','768MB') before process image.
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn