Jump to content
  • 0

Extract Emblem Blob and gzuncompress


Smoke

Question


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  34
  • Reputation:   8
  • Joined:  01/06/12
  • Last Seen:  

Hello,

I want to extract the emblem blob onto my website to show it as an image. Here's the code that i'm using :

$guild_id   = mysql_query("SELECT `guild_id` FROM `guild_member` WHERE `char_id` = '" . $row['char_id'] . "'"); // pulling from info based on another table
$guild_data = mysql_result( $guild_id, 0 );
$req   = mysql_query("SELECT `emblem_data` FROM `guild` WHERE `guild_id` = '" . $guild_data . "'");
$data  = mysql_result( $req, 0 );
$bmp = @gzuncompress(pack('H*', $data));
require_once 'functions/imagecreatefrombmpstring.php';
header('Content-type: image/png');
$img   = imagecreatefrombmpstring($bmp);
$count = mysql_num_rows( $req );

 echo "<td >";
 echo "<table border='1px' style='padding: 2px 0px 2px 7px;'>";
echo "<t";
 echo "<td width='38px'><font size='1' color='white'><b>" . $data . "</b></font></td>"; // To test whether $data is being pulled and yes it works.
// Emblem exist.
// Set header, uncompress gzip and show
echo "<td width='20'>" . imagepng($img) . "</td>"; // Website goes for a toss when i use this code without header but it doesnt show the image it either. I'm converting to png as fluxcp aswel does this I thought i'd be fine.
echo "</td>";

If someone can modify or help me with a little information with the above I'd be greatful.

Thankyou!

Edited by Smoke
Link to comment
Share on other sites

2 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  106
  • Reputation:   28
  • Joined:  11/08/11
  • Last Seen:  

You can't include the image like that, because (as you already noticed) directly insert the image data, not the image itself.

You have to put the code that generates the image in a separate file (let's say emblem.php) and include that file with image tags in your other html code. The only output for the emblem.php file will be the ImagePNG($img) call (so no echo or print calls).

Example:

<img src="emblem.php?guild_id=123">

Edited by Toshiro
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  34
  • Reputation:   8
  • Joined:  01/06/12
  • Last Seen:  

You can't include the image like that, because (as you already noticed) directly insert the image data, not the image itself.

You have to put the code that generates the image in a separate file (let's say emblem.php) and include that file with image tags in your other html code. The only output for the emblem.php file will be the ImagePNG($img) call (so no echo or print calls).

Example:

<img src="emblem.php?guild_id=123">

Well, I've been there aswel. Here's what I've learnt.

http://www.eathena.ws/board/index.php?s=&showtopic=279556&view=findpost&p=1531554

Referring to the second post on that topic.

Edited by Smoke
  • Upvote 1
Link to comment
Share on other sites

×
×
  • Create New...