Post Pacific  

Go Back   Post Pacific > Восстановленный архив > Темы без сохранившегося раздела
FAQ Community Calendar Today's Posts Search

Notices

 
 
Thread Tools Search this Thread Display Modes
Old 12.03.2007, 21:04   #1
Kane Hart
Архивный участник
 
Join Date: May 2005
Posts: 154
Default php gd l2j script help

My goal is to have this image here I can make a jpg or another version if needed but this picture here to work with php gd script show how many players are online..



I already did most the work but need someone help me finish the rest.

Heres an example: http://gamingtown.net/z/test.php

heres the code:

Code:
<?php
header ("Content-type: image/png");
//$im = imagecreatefrompng("playersonline.png");
$im = @ImageCreateFromPNG ("playersonline.png"); 
if(!$im) {
        $img_handle = ImageCreate (200, 20) or die ("Cannot Create image");
        $back_color = ImageColorAllocate ($img_handle, 0, 10, 10);
    $txt_color = ImageColorAllocate ($img_handle, 235, 235, 51);
$myFile = "online.txt";
$fh = fopen($myFile, 'r');
$theData = fgets($fh);
fclose($fh);
        ImageString ($img_handle, 10, 25, 5, "Players Online: $theData", $txt_color);
    ImagePng ($img_handle); }
Else {
    echo "Image is Found"; }
?>
Any help would be great not sure how add a background image with gd I taken this from another site and mod it a lot.. Learned how withdraw info from text file..

Its working great but want know how make work in that image above.

Thanks for all your help
Kane Hart is offline  
Old 12.03.2007, 22:09   #2
ateh
Архивный участник
 
Join Date: Apr 2006
Posts: 118
Default

This code is correct. What's not working for you?
As I understand you want to use some background and write on it?
PHP Code:
$img_handle = @ImageCreateFromPNG("playersonline.png"); 
if(!
$img_handle) {
// error to create background (no image?) use your code for this part.
} else {
        
$back_color = ImageColorAllocate ($img_handle, 0, 10, 10);
    
$txt_color = ImageColorAllocate ($img_handle, 235, 235, 51);
    
$myFile = "online.txt";
    
$fh = fopen($myFile, 'r');
    
$theData = fgets($fh);
    
fclose($fh);
        
ImageString ($img_handle, 10, 5, 5, "$theData", $txt_color);
    
ImagePng ($img_handle);
} 
just change 10, 5 to values which will set your number in proper place of image.
ateh is offline  
Old 12.03.2007, 23:25   #3
Kane Hart
Архивный участник
 
Join Date: May 2005
Posts: 154
Default

Thanks but I kind get an error :P small one

http://gamingtown.net/z/test5.php

Code:
 
‰PNG  ��� IHDR���|������xg©»���6PLTE%),яяяQTV‹ЌŽ™›ќрссЕЖЗ47:BFHввг¶ё№УФХЁ©«|€npr_bd� лл3jх]“��\IDATH‰н“лjГ0…u±дkRтю/;ЙvЪВ(ёЫІ_=ђ€ре“td€Џ>ъwUДєcZЬOŠˆбŒь\ХŸІ#єni‘-э@™ЎŸы јВ†mžЅкTПF-Ÿ{ЧГд—xC™°y3oСM, q'і&ЏнЫиёmUФ†X„y(yNx(цQт†Š•FQ$Vonэ_ъBW%7¤»] ГЭ;SµХeёq•а8Ё!CvJА@Ё¬–„јK8З±txМbјАёœђg ™[~ЗЇА+/>;ЩЗЯ Ян:R=-eќЖЁ’zvЩрШо,oБyzОЅwfЅ9±up®a‡щK6рЫЮƒѕfй·ХТYyІ–b“НXn™O_‰,±—лщL…сМЈ4OЬЮyВmСn0!фS+rцщпвиr}ƒзејяˆюД Їч^Aft±ѕ�ˆh 2ЌдE����IEND®B`‚
Kane Hart is offline  
Old 13.03.2007, 00:15   #4
m4rk
Архивный участник
 
Join Date: Jan 2006
Posts: 607
Default



Just look at it...
You need to put the number to the right.
m4rk is offline  
Old 13.03.2007, 00:20   #5
Kane Hart
Архивный участник
 
Join Date: May 2005
Posts: 154
Default

wow thanks I guess firefox has issues with it :P

Thanks it works great.

Now to learn from it. trying add font but not sure how it would look like.

I tried adding

Code:
$font = '/home/gamingto/domains/gamingtown.net/public_html/z/comicbd.ttf';
and then

Code:
        ImageString ($img_handle, 10, 95, 3, "$theData", $font, $txt_color);
Not working still learning but oh well :P
Kane Hart is offline  
Old 13.03.2007, 00:35   #6
Kane Hart
Архивный участник
 
Join Date: May 2005
Posts: 154
Default

this testing on using .png file rather then .php easy post forums that don't accept dymestic or w/e called images

Kane Hart is offline  
Old 13.03.2007, 09:25   #7
ateh
Архивный участник
 
Join Date: Apr 2006
Posts: 118
Default

Quote:
Originally Posted by Kane Hart View Post
Thanks but I kind get an error :P small one

http://gamingtown.net/z/test5.php

Code:
 
‰PNG  ��� IHDR���|������xg©»���6PLTE%),яяяQTV‹ЌŽ™›ќрссЕЖЗ47:BFHввг¶ё№УФХЁ©«|€npr_bd� лл3jх]“��\IDATH‰н“лjГ0…u±дkRтю/;ЙvЪВ(ёЫІ_=ђ€ре“td€Џ>ъwUДєcZЬOŠˆбŒь\ХŸІ#єni‘-э@™ЎŸы јВ†mžЅкTПF-Ÿ{ЧГд—xC™°y3oСM, q'і&ЏнЫиёmUФ†X„y(yNx(цQт†Š•FQ$Vonэ_ъBW%7¤»] ГЭ;SµХeёq•а8Ё!CvJА@Ё¬–„јK8З±txМbјАёœђg ™[~ЗЇА+/>;ЩЗЯ Ян:R=-eќЖЁ’zvЩрШо,oБyzОЅwfЅ9±up®a‡щK6рЫЮƒѕfй·ХТYyІ–b“НXn™O_‰,±—лщL…сМЈ4OЬЮyВmСn0!фS+rцщпвиr}ƒзејяˆюД Їч^Aft±ѕ�ˆh 2ЌдE����IEND®B`‚


you need
PHP Code:
header('Content-type: image/png'); 
at the begining.
www.php.net your friend.
ateh is offline  
Old 13.03.2007, 16:37   #8
Kane Hart
Архивный участник
 
Join Date: May 2005
Posts: 154
Default

Quote:
Originally Posted by ateh View Post
you need
PHP Code:
header('Content-type: image/png'); 
at the begining.
www.php.net your friend.
yup i figured that out :P
Kane Hart is offline  
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 15:01.