d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Iso Help With Xml Data Feed On Png > Above
Add Reply New Topic New Poll
Member
Posts: 10,964
Joined: Jun 12 2012
Gold: 1.00
Trader: Trusted
Dec 10 2019 05:33pm
Trying to create a few xml data feeds on a png but still trying to figure out how.

Do I need to edit the metadata in the iTXt tag or do I need to host a site for it?

kinda lost... any help is appreciated.
Member
Posts: 17,090
Joined: Nov 22 2008
Gold: 169.00
Dec 11 2019 03:34am
Are you planning to do this in Android studio, python, Java, JS or what?

It is possible, but you will have hard time converting PNG -> XML.

You want to do PNG -> SVG (vector) -> XML, or other way around.
This will save you bunch of time as there are bunch of libraries out there that can help you out.

But if you want to do directly XML -> PNG, post your work so far so we can work out from there.
Member
Posts: 17,311
Joined: Mar 21 2009
Gold: 3,604.22
Dec 11 2019 05:48am
Are you trying to make Ladder Slasher signatures? :P

Seems the most logical there roady boy. Pretty sure I may be able to put you in front of some people who can help if so :D

This post was edited by Kalms on Dec 11 2019 05:48am
Member
Posts: 10,964
Joined: Jun 12 2012
Gold: 1.00
Trader: Trusted
Dec 11 2019 06:42am
Quote (WeAreTheBorg @ Dec 10 2019 11:34pm)
Are you planning to do this in Android studio, python, Java, JS or what?

It is possible, but you will have hard time converting PNG -> XML.

You want to do PNG -> SVG (vector) -> XML, or other way around.
This will save you bunch of time as there are bunch of libraries out there that can help you out.

But if you want to do directly XML -> PNG, post your work so far so we can work out from there.



I may not have explained what I’m trying to do well enough. I’m trying to have dynamic xml data from a site be displayed within a png image. I’m not trying to convert the file.

Quote (Kalms @ Dec 11 2019 01:48am)
Are you trying to make Ladder Slasher signatures? :P

Seems the most logical there roady boy. Pretty sure I may be able to put you in front of some people who can help if so :D



I’ve been caught :rofl:
Member
Posts: 12,703
Joined: May 17 2013
Gold: 12,935.00
Dec 11 2019 03:05pm
Quote (roadtree @ 11 Dec 2019 13:42)
I may not have explained what I’m trying to do well enough. I’m trying to have dynamic xml data from a site be displayed within a png image. I’m not trying to convert the file.




I’ve been caught :rofl:


you need to host it somewhere if you want to link to it from d2jsp..

what language are you using? php?
Member
Posts: 10,964
Joined: Jun 12 2012
Gold: 1.00
Trader: Trusted
Dec 11 2019 03:20pm
Quote (Klexmoo @ Dec 11 2019 11:05am)
you need to host it somewhere if you want to link to it from d2jsp..

what language are you using? php?


yeah, php.

I need to find a site to host on that can support php5 and already has libgd installed on the server.

^kalms provided me with a pretty awesome link on how it's done.

it's all in php
Member
Posts: 12,703
Joined: May 17 2013
Gold: 12,935.00
Dec 11 2019 04:16pm
just do a call to this https://onlinexmltools.com/convert-xml-to-image

even shows how to do it with url parameters further down the page
Member
Posts: 10,964
Joined: Jun 12 2012
Gold: 1.00
Trader: Trusted
Dec 11 2019 05:06pm
Quote (Klexmoo @ Dec 11 2019 12:16pm)
just do a call to this https://onlinexmltools.com/convert-xml-to-image

even shows how to do it with url parameters further down the page


i appreciate the help but that's not what i'm looking for. I think I have it figured out.

got this template:

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 *
******************************************************/

// set some dimensions for future use
$expbar_width = 100;
$expbar_height = 25;

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

// set some colours for future use
$cool = imagecolorallocate($image, 81, 86, 96);
$red = imagecolorallocate($image, 255, 0, 0);
$yellow = imagecolorallocate($image, 255, 181, 53);

// 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 = '/avqest.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=146106');
$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;
$exp = (int)$exp;
$percent = calcExpPercent($exp);
$brpixelX = calcBrPixelX($exp,$expbar_width);

// Create an expbar with bg 'cool' color and the cover of your level in red.
imagefilledrectangle($image, 180, 59, 280, 71, $cool);
imagefilledrectangle($image, 180, 59, $brpixelX, 71, $red);


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

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

// EXP bar text
ImageTTFText ($image, 9, 0, 122, 69, $yellow, $font, "To Level: ");
ImageTTFText ($image, 9, 0, 220, 69, $yellow, $font, $percent."%");

//show name
ImageTTFText ($image, 9, 0, 122, 33, $yellow, $font, "HC Name: ");
ImageTTFText ($image, 9, 0, 180, 33, $red, $font, $name);

//show class
ImageTTFText ($image, 9, 0, 280, 33, $yellow, $font, "Class: ");
ImageTTFText ($image, 9, 0, 320, 33, $red, $font, $class);

// show lvl
ImageTTFText ($image, 9, 0, 122, 45, $yellow, $font, "Level: ");
ImageTTFText ($image, 9, 0, 162, 45, $red, $font, $level);

//show experience
ImageTTFText ($image, 9, 0, 180, 45, $yellow, $font, "Experience: ");
ImageTTFText ($image, 9, 0, 250, 45, $red, $font, $exp);

// show kills
ImageTTFText ($image, 9, 0, 312, 45, $yellow, $font, "Kills: ");
ImageTTFText ($image, 9, 0, 352, 45, $red, $font, $kills);

// Show HP max
ImageTTFText ($image, 9, 0, 122, 57, $yellow, $font, "HP: ");
ImageTTFText ($image, 9, 0, 145, 57, $red, $font, $hpmax);

// SHow MQ passen and attempts
ImageTTFText ($image, 9, 0, 242, 57, $yellow, $font, "MQ passes/attempts: ");
ImageTTFText ($image, 9, 0, 357, 57, $red, $font, $mqpasses."/".$mqattempts);

// Show useless shizzle
ImageTTFText ($image, 9, 0, 122, 82, $yellow, $font, "-------------------------------------");
ImageTTFText ($image, 9, 0, 122, 95, $red, $font, "GoT-Guild LadderSlasher Player | Bring ce GPs!");

// 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;
}

?>


This post was edited by roadtree on Dec 11 2019 05:06pm
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll