【问题标题】:imagecreatefromjpeg() - Invalid SOS parameters for sequential JPEGimagecreatefromjpeg() - 顺序 JPEG 的 SOS 参数无效
【发布时间】:2016-06-28 19:42:49
【问题描述】:

我无法使用 codeigniter 上传图片并出现以下错误。

遇到 PHP 错误
严重性:警告
消息: imagecreatefromjpeg():gd-jpeg,libjpeg:可恢复错误:无效 顺序 JPEG 的 SOS 参数
文件名: 库/Image_lib.php
行号:1455

PHP 错误是 遇到
严重性:警告
消息:imagecreatefromjpeg(): '/home/gsgsadh/public_html/uploads/a31d12f51b36659f5456e2530237e779.jpg' 不是有效的 JPEG 文件
文件名:libraries/Image_lib.php
行号:1455

函数image_create_gd位于application/libraries/MY_Image_lib.php

public function image_create_gd($path = '', $image_type = '')
{
    if ($path === '')
    {
        $path = $this->full_src_path;
    }

    if ($image_type === '')
    {
        $image_type = $this->image_type;
    }

    switch ($image_type)
    {
        case 1:
            if ( ! function_exists('imagecreatefromgif'))
            {
                $this->set_error(array('imglib_unsupported_imagecreate', 'imglib_gif_not_supported'));
                return FALSE;
            }

            return imagecreatefromgif($path);
        case 2:
            if ( ! function_exists('imagecreatefromjpeg'))
            {
                $this->set_error(array('imglib_unsupported_imagecreate', 'imglib_jpg_not_supported'));
                return FALSE;
            }

/*No.1455*/  return imagecreatefromjpeg($path); //****Line number is 1455****
        case 3:
            if ( ! function_exists('imagecreatefrompng'))
            {
                $this->set_error(array('imglib_unsupported_imagecreate', 'imglib_png_not_supported'));
                return FALSE;
            }

            return imagecreatefrompng($path);
        default:
            $this->set_error(array('imglib_unsupported_imagecreate'));
            return FALSE;
    }
}

解决办法是什么?如何更改代码?

【问题讨论】:

    标签: php image codeigniter


    【解决方案1】:

    设置 PHP 忽略 jpeg 警告

    ini_set ('gd.jpeg_ignore_warning', 1);
    

    就在调用 imagecreatefromjpeg() 之前的行

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-05-05
      • 1970-01-01
      • 1970-01-01
      • 2012-01-20
      • 1970-01-01
      • 2012-11-17
      • 2011-04-23
      • 2012-04-19
      相关资源
      最近更新 更多