dqc3469 2014-07-07 11:30
浏览 68
已采纳

imagefrompng质量差

I am trying to create a status image from one of our servers but the quality of the 'background image' looks really bad. Below is a link to the php file, after that is a link to the image i'm using.

http://www.tijmenschoemaker.nl/steamStatus/monitor.php

For some reason, its really bad. This is the realy image: http://www.tijmenschoemaker.nl/steamStatus/waspforum.png

<?php

/**
 * This code is free software; you can redistribute it and/or modify it under
 * the terms of the new BSD License.
 *
 * Copyright (c) 2010-2013, Sebastian Staudt
 *
 * @author  Sebastian Staudt
 * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
 * @package steam-condenser
 */

define('STEAM_CONDENSER_PATH', dirname(__FILE__) . '/');
define('STEAM_CONDENSER_VERSION', '1.3.7');

require_once STEAM_CONDENSER_PATH . 'steam/servers/GoldSrcServer.php';
require_once STEAM_CONDENSER_PATH . 'steam/servers/MasterServer.php';
require_once STEAM_CONDENSER_PATH . 'steam/servers/SourceServer.php';
require_once STEAM_CONDENSER_PATH . 'steam/community/SteamId.php';

// Set the enviroment variable for GD
putenv('GDFONTPATH=' . realpath('.'));

// Name the font to be used (note the lack of the .ttf extension)
$font = 'arial.ttf';


try{
    $server = new GoldSrcServer('127.0.0.1', 27016);
    $server->initialize();
    $playersMax = $server->infoHash['maxPlayers'];
    $servername = $server->infoHash['serverName'];
    $playersOnline = $server->infoHash['numberOfPlayers'];
    $serverName = $server->infoHash[ 'serverName'];
    $gameVersion = $server->infoHash['gameVersion'];
    $serverIP = "149.210.163.62";
    $serverPort = $server->infoHash['serverPort'];


$im = imagecreatefrompng('http://www.tijmenschoemaker.nl/steamStatus/waspforum.png')
    or die("Cannot Initialize new GD image stream");
$text_color = imagecolorallocate($im, 0,0,0);
imagestring($im, 1, 5, 12, "Server Name ".$serverName, $text_color);
imagestring($im, 1, 5, 25, "Server Adress ".$serverIP.":".$serverPort, $text_color);
imagestring($im, 1, 5, 35, "Status: Online", $text_color);
imagestring($im, 1, 5, 45, "Players ".$playersOnline."/".$playersMax."",$text_color);
imagestring($im, 1, 5, 55, "Version: ".$gameVersion, $text_color);

header("Content-Type: image/png");
imagepng($im);
imagedestroy($im);

    }
    catch(Exception $e)
    {
$im = @imagecreatefrompng('http://www.tijmenschoemaker.nl/steamStatus/waspforum.png')
    or die("Cannot Initialize new GD image stream");
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, "Offline" , $text_color);
header("Content-Type: image/png");
imagepng($im);
imagedestroy($im);

    }




?>
  • 写回答

2条回答 默认 最新

  • duanshangying5102 2014-07-07 11:38
    关注

    You can set transparent background with this code:

        $trans = imagecolorallocatealpha($im, 0, 0, 0, 127);
        imagesavealpha($im, true);
        imagefill($im, 0, 0, $trans);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单