imagecreatefromjpeg()注意事项

在工作中碰到一个这样的问题,有些图片没有,有些又有,很奇怪。

imagecreatefromjpeg(): gd-jpeg, libjpeg: recoverable error: Premature end of JPEG file

百度了一下imagecreatefromjpeg这个函数

Zane, MegaLab.it   14-Jul-2011 09:07

Some image where failing with a Warning: imagecreatefromjpeg(): gd-jpeg, libjpeg: recoverable error: Premature end of JPEG file

The only way to make it work was to ini_set("gd.jpeg_ignore_warning", 1); and then call it with @imagecreatefromjpeg()

It's far less than ideal, but if you're stuck as I was, give it a try.

有这样一段话,于是程序中加入ini_set("gd.jpeg_ignore_warning", 1);

再在每次调用imagecreatefromjpeg这个函数前面加个@,问题解决了。

事实证明,没事看看文档还是很有用的。

你可能感兴趣的:(php)