d2jsp
Log InRegister
d2jsp Forums > d2jsp > Ladder Slasher > Guide: How-to Make A Dynamic Ladder-slasher Sig > In A Few Easy Steps With Pics
Prev1141516171860Next
Add Reply New Topic New Poll
Member
Posts: 1,909
Joined: May 8 2007
Gold: 2,507.26
Nov 21 2008 09:55am
Maybe you can try varying on the quality:

Code
imagejpeg ( resource $image [, string $filename [, int $quality ]] )


so

Code
imagejpeg($img,NULL,85)


should vaary to 85%. If you compress your image background while saving, maybe it is not a good idea to go over the compressing quality. So if in, for instance photoshop, you set jpeg compression to 85% or something, you should not go higher than 85%. But this may be complete nonsense. Worth a try? I dunno tongue.gif.


Member
Posts: 20,664
Joined: Aug 20 2006
Gold: 620.00
Nov 21 2008 11:35am
tried to upload but it doesnt work sad.gif

uploading
1. myimg.png
2. .htaccess
3. text.png.php5

Code
<?php
Header ('Content-type: image/jpeg');
Header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
Header('Expires: Thu, 19 Nov 1981 08:52:00 GMT');
Header('Pragma: no-cache');

/******************************************************
*                    BASICS                        *
******************************************************/



// create the image from a background jpg
$image = imagecreatefrompng('lssigcleanlb2.png');


$grey = imagecolorallocate($image, 240, 240, 240);

// set the background colour
// number or is top left pixel x, top left pixel y, bottom right pixel x, bottom right pixel y

// set the font and print text
$font = '/folkard_.TTF';

/******************************************************
*                    LOAD DATA                      *
******************************************************/

// Create an array for determining the class you play.
// In the XML this is saved as an int number, the conversion is shown below.
$class_name = array(  -1 => 'None',
   0 => 'Fighter',
   1 => 'Barbarian',
   2 => 'Rogue',
   3 => 'Magician',
 4 => 'Guardian',
   5 => 'Samurai',
   6 => 'Paladin',
   7 => 'Monk',
   8 => 'Ninja',
   9 => 'Warlock',
   10 => 'Headhunter',
   11=> 'Alchemist');

// load xml data in vars

// This is where you load your own info from the xml d2jsp gives. This is a PHP5 only command!
$data = simplexml_load_file('http://ladderslasher.d2jsp.org/xmlChar.php?i=88646');
$name = $data->name;
$kills = $data->kills;
$class = $class_name[(int)$data->classid];
$exp = $data->exp;
$level = $data->level;
$hpmax = $data->hpmax;
$mqpasses = $data->mqpasses;
$mqattempts = $data->mqattempts;
$strenght = $data->strength;
$dexterity = $data->dexterity;
$exp = (int)$exp;
$percent = calcExpPercent($exp);
$brpixelX = calcBrPixelX($exp,$expbar_width);


/******************************************************
*                    TEXT PART                      *
******************************************************/

//Example; ImageTTFText ($image, textsize, angle, right indent, down indent, color, font, "text");



//show class
ImageTTFText ($image, 11, 0, 136, 49, $grey, $font, $class);


// show lvl
ImageTTFText ($image, 10, 0, 186, 49, $grey, $font, "lvl ");
ImageTTFText ($image, 10, 0, 211, 49, $grey, $font, $level);

// show strength
ImageTTFText ($image, 10, 0, 143, 66, $grey, $font, "Str ");
ImageTTFText ($image, 10, 0, 176, 66, $grey, $font, $strenght);

// show dexterity
ImageTTFText ($image, 10, 0, 204, 66, $grey, $font, "Dex ");
ImageTTFText ($image, 10, 0, 236, 66, $grey, $font, $dexterity);

// show kills
ImageTTFText ($image, 10, 0, 312, 45, $grey, $font, "Kills ");
ImageTTFText ($image, 10, 0, 352, 45, $grey, $font, $kills);


// SHow MQ passen and attempts
ImageTTFText ($image, 10, 0, 151, 99, $grey, $font, "Master ");
ImageTTFText ($image, 10, 0, 165, 109, $grey, $font, "Quests ");
ImageTTFText ($image, 10, 0, 218, 102, $grey, $font, $mqpasses."/".$mqattempts);


// output and destroy
imagepng($image);
imagedestroy($image);


/******************************************************
*                    FUNCTIONS                      *
******************************************************/

/***
* calculate the exp bar width.
***/
function calcBrPixelX($input,$xpbar_width)
 {
$temp1 = fmod($input,1000000);
$temp1 = ($temp1/1000000);
$temp1 = $temp1 * $xpbar_width;
$temp1 = $temp1 + 180;

return (int)$temp1;
 }

/***
* Calculate the percentage of level done
***/
function calcExpPercent($input)
{
$temp1 = fmod($input,1000000);
$temp1 = ($temp1/1000000);
$temp1 = $temp1 * 100;

return (int)$temp1;
}

?>


in one directory
is there anything wrong?

This post was edited by erasko on Nov 21 2008 11:36am
Member
Posts: 10,092
Joined: Dec 9 2007
Gold: Locked
Nov 21 2008 12:30pm
Quote (erasko @ Fri, 21 Nov 2008, 18:35)
tried to upload but it doesnt work sad.gif

uploading
1. myimg.png
2. .htaccess
3. text.png.php5

Code
<?php
Header ('Content-type: image/jpeg');
Header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
Header('Expires: Thu, 19 Nov 1981 08:52:00 GMT');
Header('Pragma: no-cache');

/******************************************************
*                    BASICS                        *
******************************************************/



// create the image from a background jpg
$image = imagecreatefrompng('lssigcleanlb2.png');


$grey = imagecolorallocate($image, 240, 240, 240);

// set the background colour
// number or is top left pixel x, top left pixel y, bottom right pixel x, bottom right pixel y

// set the font and print text
$font = '/folkard_.TTF';

/******************************************************
*                    LOAD DATA                      *
******************************************************/

// Create an array for determining the class you play.
// In the XML this is saved as an int number, the conversion is shown below.
$class_name = array(  -1 => 'None',
   0 => 'Fighter',
   1 => 'Barbarian',
   2 => 'Rogue',
   3 => 'Magician',
 4 => 'Guardian',
   5 => 'Samurai',
   6 => 'Paladin',
   7 => 'Monk',
   8 => 'Ninja',
   9 => 'Warlock',
   10 => 'Headhunter',
   11=> 'Alchemist');

// load xml data in vars

// This is where you load your own info from the xml d2jsp gives. This is a PHP5 only command!
$data = simplexml_load_file('http://ladderslasher.d2jsp.org/xmlChar.php?i=88646');
$name = $data->name;
$kills = $data->kills;
$class = $class_name[(int)$data->classid];
$exp = $data->exp;
$level = $data->level;
$hpmax = $data->hpmax;
$mqpasses = $data->mqpasses;
$mqattempts = $data->mqattempts;
$strenght = $data->strength;
$dexterity = $data->dexterity;
$exp = (int)$exp;
$percent = calcExpPercent($exp);
$brpixelX = calcBrPixelX($exp,$expbar_width);


/******************************************************
*                    TEXT PART                      *
******************************************************/

//Example; ImageTTFText ($image, textsize, angle, right indent, down indent, color, font, "text");



//show class
ImageTTFText ($image, 11, 0, 136, 49, $grey, $font, $class);


// show lvl
ImageTTFText ($image, 10, 0, 186, 49, $grey, $font, "lvl ");
ImageTTFText ($image, 10, 0, 211, 49, $grey, $font, $level);

// show strength
ImageTTFText ($image, 10, 0, 143, 66, $grey, $font, "Str ");
ImageTTFText ($image, 10, 0, 176, 66, $grey, $font, $strenght);

// show dexterity
ImageTTFText ($image, 10, 0, 204, 66, $grey, $font, "Dex ");
ImageTTFText ($image, 10, 0, 236, 66, $grey, $font, $dexterity);

// show kills
ImageTTFText ($image, 10, 0, 312, 45, $grey, $font, "Kills ");
ImageTTFText ($image, 10, 0, 352, 45, $grey, $font, $kills);


// SHow MQ passen and attempts
ImageTTFText ($image, 10, 0, 151, 99, $grey, $font, "Master ");
ImageTTFText ($image, 10, 0, 165, 109, $grey, $font, "Quests ");
ImageTTFText ($image, 10, 0, 218, 102, $grey, $font, $mqpasses."/".$mqattempts);


// output and destroy
imagepng($image);
imagedestroy($image);


/******************************************************
*                    FUNCTIONS                      *
******************************************************/

/***
* calculate the exp bar width.
***/
function calcBrPixelX($input,$xpbar_width)
 {
$temp1 = fmod($input,1000000);
$temp1 = ($temp1/1000000);
$temp1 = $temp1 * $xpbar_width;
$temp1 = $temp1 + 180;

return (int)$temp1;
 }

/***
* Calculate the percentage of level done
***/
function calcExpPercent($input)
{
$temp1 = fmod($input,1000000);
$temp1 = ($temp1/1000000);
$temp1 = $temp1 * 100;

return (int)$temp1;
}

?>


in one directory
is there anything wrong?


pm me, i'll u explain u all smile.gif
Member
Posts: 5,467
Joined: Jul 12 2008
Gold: 6,350.87
Nov 22 2008 07:28pm
how can i add 2nd and mb 3rd font and use it? unsure.gif

This post was edited by SkilletFan on Nov 22 2008 07:28pm
Member
Posts: 22,875
Joined: Apr 7 2006
Gold: 1,250.46
Nov 22 2008 07:38pm
Quote (SkilletFan @ Sat, Nov 22 2008, 08:28pm)
how can i add 2nd and mb 3rd font and use it? unsure.gif


Quote
/******************************************************
* BASICS *
******************************************************/



// create the image from a background jpg
$image = imagecreatefrompng('lssigcleanlb2.png');


$grey = imagecolorallocate($image, 240, 240, 240);

// set the background colour
// number or is top left pixel x, top left pixel y, bottom right pixel x, bottom right pixel y

// set the font and print text
$font = '/folkard_.TTF';



--- just upload whatever font you want to use to your working directory and add a new variable.

ex.)
$font = 'folkard_.TTF';
$font2 = 'tahoma.ttf';
$font3 = 'terminal.ttf;

then when adding the text

// SHow MQ passen and attempts
ImageTTFText ($image, 10, 0, 151, 99, $grey, $font, "Master ");
ImageTTFText ($image, 10, 0, 165, 109, $grey, $font2, "Quests ");
ImageTTFText ($image, 10, 0, 218, 102, $grey, $font3, $mqpasses."/".$mqattempts);

This post was edited by cardoors32 on Nov 22 2008 07:38pm
Member
Posts: 20,664
Joined: Aug 20 2006
Gold: 620.00
Nov 24 2008 01:57pm
how to upload a .gif?
I uploaded
sig.gif
text.gif.php
font
.htaccess

and edited
imagecreatefrompng
to
imagecreatefromgif

what else to do?
I uploaded it but its not showing animation biggrin.gif
Member
Posts: 5,997
Joined: Sep 7 2008
Gold: 70.00
Nov 24 2008 03:10pm
nice i'm going to do one tomorrow smile.gif
Member
Posts: 873
Joined: May 19 2007
Gold: 12,066.74
Nov 24 2008 08:10pm
Here is some code if you want it to randomly show differant chars of your own...

add array code near the class array (changing to your own char links ofc)
Code
$data_array = array('http://ladderslasher.d2jsp.org/xmlChar.php?i=124752',
            'http://ladderslasher.d2jsp.org/xmlChar.php?i=165990',
            'http://ladderslasher.d2jsp.org/xmlChar.php?i=163662',
            'http://ladderslasher.d2jsp.org/xmlChar.php?i=173175',
           'http://ladderslasher.d2jsp.org/xmlChar.php?i=164094');
shuffle($data_array);

and change
Code
$data = simplexml_load_file('http://ladderslasher.d2jsp.org/xmlChar.php?i=65938');
to
Code
$data = simplexml_load_file($data_array[0]);


You can reload my sig a couple of times to see it work. Also you could associate the background picture whith the char and have it change as well.

This post was edited by mcweaze on Nov 24 2008 08:14pm
Member
Posts: 873
Joined: May 19 2007
Gold: 12,066.74
Nov 24 2008 09:52pm
If you wish to add a random background

Code

$img_array = array('mcweaze.png', 'mcweaze1.png', 'mcweaze2.png', 'mcweaze3.png');
shuffle($img_array);

$image = imagecreatefrompng($img_array[0]);
Member
Posts: 1,752
Joined: Jan 20 2008
Gold: 892.00
Nov 24 2008 10:26pm
sweet
Go Back To Ladder Slasher Topic List
Prev1141516171860Next
Add Reply New Topic New Poll