出现 jpeg 错误
<?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 行
警告: imagecreatefromjpeg() [function.imagecreatefromjpeg]: 'images /frame.jpeg' 不是 /home2/puneetbh/public_html/prideapp/frame.php 第 11 行中的有效 JPEG 文件
警告:imagecopymerge():提供的参数不是 /home2/puneetbh/public_html/prideapp 中的有效图像资源/frame.php 第 16 行
警告:无法修改标头信息 - 已由 /home2/puneetbh/public_html/prideapp/frame.php:11 中的 /home2/puneetbh/public_html/prideapp/frame.php 中的输出(输出开始)发送的标头第 34 行
警告:imagejpeg():提供的参数不是 /home2/puneetbh/public_html/prideapp/frame.php 中的有效图像资源 第 35 行
警告:imagedestroy():提供的参数不是 /home2 中的有效图像资源/puneetbh/public_html/prideapp/frame.php 第 36 行
<?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);
?>
i am getting error
arning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg: JPEG library reports unrecoverable error: in /home2/puneetbh/public_html/prideapp/frame.php on line 11
Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: 'images/frame.jpeg' is not a valid JPEG file in /home2/puneetbh/public_html/prideapp/frame.php on line 11
Warning: imagecopymerge(): supplied argument is not a valid Image resource in /home2/puneetbh/public_html/prideapp/frame.php on line 16
Warning: Cannot modify header information - headers already sent by (output started at /home2/puneetbh/public_html/prideapp/frame.php:11) in /home2/puneetbh/public_html/prideapp/frame.php on line 34
Warning: imagejpeg(): supplied argument is not a valid Image resource in /home2/puneetbh/public_html/prideapp/frame.php on line 35
Warning: imagedestroy(): supplied argument is not a valid Image resource in /home2/puneetbh/public_html/prideapp/frame.php on line 36
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题的根源在于
可能该文件已损坏,也可能是 CMYK 图像。
您应该检查 imagecreatefromjpeg() 是否返回 false,并在这种情况下停止执行脚本,并可能输出错误消息。
The root of the problem is
maybe the file is broken, maybe it is a CMYK image.
You should check whether
imagecreatefromjpeg()
returns false, and stop execution of the script in that case and maybe output an error message.