调整png大小的问题

时间:2011-05-04 18:47:16

标签: php resize png

我在使用此脚本调整我的Minecraft皮肤时出现问题。 当我在我的本地主机上测试它时,一切都很好,但当我上传它的服务器时,它只显示一个调整大小的透明图像,没有内容。 这是脚本:

<?php
function clean($str) {
    $str = @trim($str);
    if(get_magic_quotes_gpc()) {
        $str = stripslashes($str);
    }
    return mysql_real_escape_string($str);
 }

// File and new size
$fil = clean($_GET['skin']);

 header('Content-type: image/png');
//$myimage = resizeImage('filename', 'newwidthmax', 'newheightmax');

function resizeImage($filename, $newwidth, $newheight){
list($width, $height) = getimagesize($filename);

$thumb = imagecreatetruecolor($newwidth, $newheight);
$transparent = imagecolorallocate($thumb, 200, 255, 200);
imagefill($thumb, 0, 0, $transparent);
imagecolortransparent($thumb, $transparent);

$source = imagecreatefrompng($filename);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

return imagepng($thumb);
}

$myimage = resizeImage($fil, '640', '320');
print $myimage;

?>

您可以在此处查看输出:link

1 个答案:

答案 0 :(得分:0)

mysql_real_escape_string需要已经打开的mysql连接。它将使用最后打开的连接,如果不存在则返回false。也许这就是你错过数据的地方。

相关问题