可怕的“Warning:imagecreatefromjpeg():'/ tmp / filename'不是xxx行中的/phpfile.php中的有效JPEG文件” [英] the dreaded "Warning: imagecreatefromjpeg() : '/tmp/filename' is not a valid JPEG file in /phpfile.php on line xxx"

查看:759
本文介绍了可怕的“Warning:imagecreatefromjpeg():'/ tmp / filename'不是xxx行中的/phpfile.php中的有效JPEG文件”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


警告:imagecreatefromjpeg()
我有一些人上传图片到我们的网站[function.imagecreatefromjpeg]:
gd-jpeg:JPEG库报告
不可恢复的错误:
/home/pathremoved/includes/snapsutils.php
在第220行



警告:imagecreatefromjpeg()
[function.imagecreatefromjpeg]:
'/ tmp / phpiw4MFk'不是/ home / pathremoved.php on
220

警告:imagesx():提供的参数
不是
/ home中的有效Image资源警告:imagesy():提供的参数

/ home / pathremoved中不是有效的图像资源。

警告:imagecreatetruecolor()
[function.imagecreatetruecolor]:
无效的图像尺寸在
/ home / pathremoved .php on line 240



Warni ng:imagecopyresampled():
提供的参数不是在
行242上的/home/pathremoved.php中有效的Image
资源

这只发生在某些图像上,当在任何程序中打开的时候,它甚至可以上传到我在本地主机上的版本,没有问题...我google了一下,但发现没有定论...

注意php upload_max大小是5M和post_max_size是5M。这不是上传或内存问题。我已经测试了4M图像没有问题。

任何帮助表示赞赏。

解决方案这个bug报告。 GD库似乎不像其他程序那样容忍有问题的JPEG文件。建议的解决方法是在处理图像之前设置GD忽略JPEG错误,如下所示:

  ini_set(gd.jpeg_ignore_warning ,1); 

希望这会对您有用。你可能遇到的另一个潜在的问题是与内存有关。看起来,GD一旦打开,就将所有图像保存在位图中。这意味着一个5MB的图像实际上可以消耗比单个PHP线程更多的内存,导致一个致命的错误。我有一些图片上传的问题,并不得不减少我允许解决这个问题的最大文件大小。

祝你好运,希望有所帮助。


I've been getting this warning when some people upload images to our site :

Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg: JPEG library reports unrecoverable error: in /home/pathremoved/includes/snapsutils.php on line 220

Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: '/tmp/phpiw4MFk' is not a valid JPEG file in /home/pathremoved.php on line 220

Warning: imagesx(): supplied argument is not a valid Image resource in /home/pathremoved.php on line 222

Warning: imagesy(): supplied argument is not a valid Image resource in /home/pathremoved.php on line 223

Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /home/pathremoved.php on line 240

Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/pathremoved.php on line 242

This only happens with certain images, which when opened in any program are ok, it even uploads to the version of the site I have on localhost with no problems...I googled a bit but found nothing conclusive...

note php upload_max size is 5M and post_max_size is 5M. This is not an upload or memory issue. I've tested with 4M images without problems.

any help appreciated.

解决方案

After a little digging around on Google I found this bug report. It seems that the GD library is less tolerant of buggy JPEG files than other programs. The solution suggested was to set GD to ignore JPEG error's before processing the image, like this:

ini_set("gd.jpeg_ignore_warning", 1);

Hopefully that will work for you. One other potential problem you may run into is to do with memory. It seems that GD holds all images in memory as bitmaps once they've been opened. This means that a 5MB image can actually consume more memory than a single PHP thread is allowed, resulting in a fatal error. I had this problem with some image uploads and had to reduce the maximum file size I allowed to get around the problem.

Good luck and hope that helps.

这篇关于可怕的“Warning:imagecreatefromjpeg():'/ tmp / filename'不是xxx行中的/phpfile.php中的有效JPEG文件”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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