【问题标题】:getting jpeg error得到 jpeg 错误
【发布时间】:2010-05-08 05:58:57
【问题描述】:
<?php

function LoadPNG()
{
    /* Attempt to open */
    //require_once 'resizex.php';
    $imgname="/home2/puneetbh/public_html/prideofhome/wp-content/uploads/268995481image_11.png";
    //$im = @imagecreatefrompng($imgname);
    $img= imagecreatefromstring(file_get_contents($imgname));
    //$im=imagecreatefrompng('images/frame.png');
    $im= imagecreatefromjpeg('images/frame.jpeg');
    //imagealphablending($img, false);
    //imagesavealpha($img, true);

    //$img=resizex("$url",60,65,1);
    imagecopymerge($im,$img,105,93,0, 0,275,258,100);
    /* See if it failed */
    if(!$im)
    {
        /* Create a blank image */
        $im  = imagecreatetruecolor(150, 30);
        $bgc = imagecolorallocate($im, 255, 255, 255);
        $tc  = imagecolorallocate($im, 0, 0, 0);

        imagefilledrectangle($im, 0, 0, 150, 30, $bgc);

        /* Output an error message */
        imagestring($im, 1, 5, 5, 'Error loading ' . $imgname, $tc);
    }

    return $im;
}
$img = LoadPNG();
header('Content-type: image/jpeg');
imagejpeg($im);
imagedestroy($im);
imagedestroy($img);

?>

我收到错误 arning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg: JPEG library reports unrecoverable error: in /home2/puneetbh/public_html/prideapp/frame.php on line 11

警告:imagecreatefromjpeg() [function.imagecreatefromjpeg]: 'images/frame.jpeg' 不是第 11 行 /home2/puneetbh/public_html/prideapp/frame.php 中的有效 JPEG 文件

警告:imagecopymerge():提供的参数不是第 16 行 /home2/puneetbh/public_html/prideapp/frame.php 中的有效图像资源

警告:无法修改标头信息 - 标头已由第 34 行 /home2/puneetbh/public_html/prideapp/frame.php 中的 /home2/puneetbh/public_html/prideapp/frame.php:11 发送的标头

警告:imagejpeg():提供的参数不是第 35 行 /home2/puneetbh/public_html/prideapp/frame.php 中的有效图像资源

警告:imagedestroy():提供的参数不是第 36 行 /home2/puneetbh/public_html/prideapp/frame.php 中的有效图像资源

【问题讨论】:

  • 请编辑您的问题以将其格式化为代码。
  • 选择编码部分并按下“010101”按钮以获得完美的外观,并使用“编辑器按钮”对警告和错误进行注释
  • 错误消息表明 GD 库确实找到了文件 images/frame.jpeg,但它不是有效的 JPEG 文件。您能否上传一份此文件的副本,以便我们看一看?

标签: php gd


【解决方案1】:

问题的根源是

'images/frame.jpeg' 不是有效的 JPEG 文件

可能是文件损坏了,可能是 CMYK 图像。

您应该检查imagecreatefromjpeg()是否返回false,在这种情况下停止执行脚本并可能输出错误消息。

【讨论】:

  • 还要检查是否将路径作为浏览器的 url 给你图像?
猜你喜欢
  • 1970-01-01
  • 2013-09-30
  • 2011-09-21
  • 2016-06-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-02-22
相关资源
最近更新 更多