2010-05-08 120 views
0
<?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库报告不可恢复的错误:在上线/home2/puneetbh/public_html/prideapp/frame.php 11越来越JPEG错误

警告:imagecreatefromjpeg()[function.imagecreatefromjpeg]: '图像/ frame.jpeg' 不是在/home2/puneetbh/public_html/prideapp/frame.php第11行

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

警告:不能更改头信息 - 头已经发出在/home2/puneetbh/public_html/prideapp/frame.php(输出开始/home2/puneetbh/public_html/prideapp/frame.php:11)上线34

警告:imagejpeg():提供的参数不是在/home2/puneetbh/public_html/prideapp/frame.php有效的图片资源上线35

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

+1

请编辑您的问题,将其格式化为代码。 – 2010-05-08 06:00:50

+0

选择编码部分并按下“010101”按钮以获得完美的外观,并使用编辑器的按钮“ – 2010-05-08 06:06:18

+0

”发出警告和错误。错误消息表示GD库确实找到了“images/frame.jpeg”文件,但是它不是一个有效的JPEG文件,你能上传这个文件的副本,以便我们可以看一看吗? – erisco 2010-05-08 06:12:16

回答

1

问题的根源是

'images/frame.jpeg' is not a valid JPEG file

也许文件坏了,也许它是一个CMYK图像。

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

+0

此外,检查是否将路径作为URL到浏览器给你或不是? – 2010-05-08 06:10:04