<?php
function LoadPNG($imgname)
{
/* Attempt to open */
$im = @imagecreatefrompng($imgname);
/* 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;
}
header('Content-Type: image/png');
$img = LoadPNG('http://www.prideofhome.com/wp-content/uploads/328145505image_11.png');
imagepng($img);
imagedestroy($img);
?>我从the获取error..how到solve.is镜像创建不支持来自远程服务器的文件。
发布于 2010-05-06 16:57:24
要使用远程服务器中的文件,请结合使用imagecreatefromstring和file_get_contents:
$im = imagecreatefromstring(file_get_contents($imgname));请注意,只有在启用了file_get_contents包装器的情况下,URL才能用作带有fopen的文件名。
如果这不能解决你的问题,那就澄清你的问题。至少给出你收到的错误。:)
发布于 2010-05-06 16:59:29
移除@会让您看到哪里出了问题。可能是apppropriate option没有设置,或者gd扩展没有PNG支持,或者远程文件不存在/无法下载。
https://stackoverflow.com/questions/2779725
复制相似问题