dzhax Posted February 23, 2009 Share Posted February 23, 2009 I am making a dynamic image script. It works but I want to make it look better. <?phpheader("Content-type: image/png");$dip = $_GET['ip'];$sigName='dsig1';$dport='43594';$fp = @fsockopen($dip, $dport, $errno, $errstr, 1);if (!$fp) {$string='Offline';} else {$string='Online';}$im = imagecreatefrompng("images/".$sigName.".png");$orange = imagecolorallocate($im, 220, 210, 60);imagestring($im, 3, 60, 47,$string, $orange);imagestring($im,3, 60, 29, $dport, $orange);imagestring($im,3, 60, 11, $dip, $orange);imagepng($im);imagedestroy($im);?> This is what I have.I want to change the dynamic text font to comic sans.Anyone know how to do this? Link to comment Share on other sites More sharing options...
Synook Posted February 23, 2009 Share Posted February 23, 2009 http://www.php.net/manual/en/function.imagettftext.php Link to comment Share on other sites More sharing options...
dzhax Posted February 23, 2009 Author Share Posted February 23, 2009 http://www.php.net/manual/en/function.imagettftext.phpDo I just add that or does a line need replaced? Link to comment Share on other sites More sharing options...
justsomeguy Posted February 23, 2009 Share Posted February 23, 2009 That's a reference page that describes how to use TrueType fonts in an image. There is another page for PostScript fonts if you want to use those instead. Link to comment Share on other sites More sharing options...
dzhax Posted February 23, 2009 Author Share Posted February 23, 2009 That's a reference page that describes how to use TrueType fonts in an image. There is another page for PostScript fonts if you want to use those instead.I know its a reference page. I was talking about the code it refrences.Do I replace a line from my script with the line described on the link or do I just add it to my existing script. Link to comment Share on other sites More sharing options...
justsomeguy Posted February 24, 2009 Share Posted February 24, 2009 You would replace lines that use imagestring with lines that use imagettftext or imagepstext. Make sure you have the font files available to the script. Link to comment Share on other sites More sharing options...
dzhax Posted February 24, 2009 Author Share Posted February 24, 2009 this is weird i have a true type font and its not working. <?phpheader("Content-type: image/png");$dip = 'dzhax.com';$dport = '43594';$sigNum = '0';$im = imagecreatefrompng("http://www.dzhax.com/images/dsig".$sigNum.".png");$font = 'data/comic.ttf';$orange = imagecolorallocate($im, 220, 210, 60);$fp = @fsockopen($dip, $dport, $errno, $errstr, 0);if (!$fp) {$string='Server Currently: Offline';} else {$string='Server Currently: Online';}imagettftext($im,5,0,100,100,$orange,$font,$string);imagepng($im);imagedestroy($im);?> Link to comment Share on other sites More sharing options...
Synook Posted February 24, 2009 Share Posted February 24, 2009 You need to have the Freetype library installed on your server. It's not common... Link to comment Share on other sites More sharing options...
justsomeguy Posted February 24, 2009 Share Posted February 24, 2009 It might also be looking for the wrong file: Depending on which version of the GD library PHP is using, when fontfile does not begin with a leading / then .ttf will be appended to the filename and the library will attempt to search for that filename along a library-defined font path.Try removing .ttf from the filename. Also, have errors go to an error log, you probably won't see errors since you're sending the image headers.error_reporting(E_ALL);ini_set('error_log', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'error.log');ini_set('html_errors', 0);ini_set('log_errors', 1);ini_set('display_errors', 0);That will set up a file called error.log in the same folder with any error messages. Link to comment Share on other sites More sharing options...
dzhax Posted February 25, 2009 Author Share Posted February 25, 2009 Sry for being a pain on this. I just really don't understand what is wrong. It is probably something stupid too. I provided an image so if you want to you can test it.www.dzhax.com/images/dsig0.pngI also imported the config file from my other post.I am guessing it dosent like the im$ variable, but it works with imagestring... i dunno. <?phpheader("Content-type: image/png");$dname = @$_GET['name'];$font = 'data/comic';include('server/hiscore/'.$dname."/config1.php");$fp = @fsockopen($dip, $dport, $errno, $errstr, 0);if (!$fp) {$string='Offline';} else {$string='Online';}$im = imagecreatefrompng("images/dsig".$sigNum.".png");$orange = imagecolorallocate($im, 220, 210, 60);imagettftext($im,5,0,100,100,$orange,$font,$string);error_reporting(E_ALL);ini_set('error_log', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'error.log');ini_set('html_errors', 0);ini_set('log_errors', 1);ini_set('display_errors', 0);imagepng($im);imagedestroy($im);?> Error Log:[25-Feb-2009 01:03:31] PHP Warning: imagepng(): supplied argument is not a valid Image resource in C:\www\vhosts\localhost\dynamic1.php on line 16[25-Feb-2009 01:03:31] PHP Warning: imagedestroy(): supplied argument is not a valid Image resource in C:\www\vhosts\localhost\dynamic1.php on line 17 Link to comment Share on other sites More sharing options...
justsomeguy Posted February 25, 2009 Share Posted February 25, 2009 It doesn't look like $signum is set. Move the error reporting code higher up, there are probably errors happening before you try to save the image. Link to comment Share on other sites More sharing options...
dzhax Posted February 26, 2009 Author Share Posted February 26, 2009 for some reason is suddenly started to work. Thanks man. U guys are the best. Kudos to you. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.