Log in

View Full Version : HELP: Speech Bubble Generator



nickyp88
25-06-2010, 02:15 AM
On a previous post, I was asking how to get a Speech Bubble Generator I ripped from a website to generate pictures. This time, I'm asking how to code the page which has the speech bubble you generated on it. I coded my own Speech Bubble Generator. I got it to generate through habboemotion.com's "bubble.php" file which is what I'm looking for.
here is the JavaScript I coded:


/* the function that gathers all the info */
function submitBubblegen()
{
var country = document.getElementById('country').value;
var habbo = document.getElementById('habbo').value;
var text = escape(document.getElementById('text').value);
var format = document.getElementById('format').value;
var habbo_avatar = "http://habboemotion.com/usable/bubble/bubble.php?habbo="+habbo+"&country="+country+"&text="+text+"&format="+format+"";
var habbourl = document.getElementById('habbourl').value = habbo_avatar;
var habboimg = document.getElementById('habboimg').src = habbo_avatar;
}If you see, I put habboemotion.com's bubble.php url so it could generate the speech bubbles. It works pretty good, I just wanna figure out how to code that bubble.php page into generating that image onto my site. Does anyone know how to code this page?

Apolva
25-06-2010, 11:33 AM
You'll need to learn PHP and how to use the PHP GD image library for creating images.

Trigs
26-06-2010, 07:05 PM
Correct me if I'm wrong but I don't see why you need info from Habbo to create this.

Just use an image of the speech bubble as use GD (as Apolva said) to dynamically create the text.

First create a form that asks what text you want to display. Name the field "msg" (without the quotes). Use the code below (I commented it so you should understand what's happening within the code). You'll have to upload the font you want to use to the server you're hosting this on and the image of the speech bubble as well. Then change the links in the code. Also, you'll have to mess with $x and $y to position the text correctly. Let me know if you have any problems.



<?php
$txt = $_POST['msg']; // Text you want displayed (pulled from the form)
$x = 'CHANGEME'; // x-coordinate
$y = 'CHANGEME'; // y-coordinate

$font = 'CHANGE ME'; // Path to font
$fontsize = '12'; // Size of the font in px
$angle = '0'; // Angle of the text
$img = imagecreatefrompng('CHANGEME'); // Specifies the image we want to use
$colour = imagecolorallocate($img, 255, 255, 255); // Specifies the font colour
imagettftext($img, $fontsize, $angle, $x, $y, $colour, $font, $txt); // Displays our text on the image
imagepng($img);
imagedestroy($img);
?>

Jack!
27-06-2010, 08:12 PM
Correct me if I'm wrong but I don't see why you need info from Habbo to create this.

Just use an image of the speech bubble as use GD (as Apolva said) to dynamically create the text.

First create a form that asks what text you want to display. Name the field "msg" (without the quotes). Use the code below (I commented it so you should understand what's happening within the code). You'll have to upload the font you want to use to the server you're hosting this on and the image of the speech bubble as well. Then change the links in the code. Also, you'll have to mess with $x and $y to position the text correctly. Let me know if you have any problems.



<?php
$txt = $_POST['msg']; // Text you want displayed (pulled from the form)
$x = 'CHANGEME'; // x-coordinate
$y = 'CHANGEME'; // y-coordinate

$font = 'CHANGE ME'; // Path to font
$fontsize = '12'; // Size of the font in px
$angle = '0'; // Angle of the text
$img = imagecreatefrompng('CHANGEME'); // Specifies the image we want to use
$colour = imagecolorallocate($img, 255, 255, 255); // Specifies the font colour
imagettftext($img, $fontsize, $angle, $x, $y, $colour, $font, $txt); // Displays our text on the image
imagepng($img);
imagedestroy($img);
?>


for the little image of the habbo's head in the text box

Have you tired just copying the file from habbo emotion?

Apolva
27-06-2010, 08:26 PM
You can pretend that you have the script (make the image come from your own domain, for example if you need it for SSL, which you probably don't) using something like:
<?php
header("Content-type: image/png");
readfile("http://habboemotion.com/usable/bubble/bubble.php?habbo=".$_GET['habbo']);
?>

Note that it will still just download the file and therefore relies on the site to be up (which isn't exactly ideal + is slower).

Trigs
28-06-2010, 01:46 AM
If you know the URL that Habbo uses to dynamically pull images of certain Habbo's then it could be done easily.

If you want to just rip it (not recommended) then try this:



edit - wait made a bunch of errors, don't use the code yet im working on it.

edit 2 - is this what you want? http://totalbasketball.herobo.com/test/habbotest.php
if so, let me know and I'll fix up it up for you (add the country list options, say/whisper/shout, etc.)

nickyp88
29-06-2010, 07:07 PM
Fazon, that is exactly what I want.

Trigs
29-06-2010, 07:27 PM
I'll post the code tonight, I'm a bit busy right now.

Keep in mind that this is hotlinking habboemotion.com and they might not take to kindly to it.

nickyp88
29-06-2010, 07:56 PM
Fazon, i'm trying to use the GD imaging thing but im having problems. can you code the form 4 me? cuz idk what im doing. And where do u put the form?

Trigs
29-06-2010, 09:26 PM
Hold on, I'll send you the complete code. I recommend you learn some PHP though so next time you know how to do it yourself.

nickyp88
29-06-2010, 09:37 PM
ok. i will start learning PHP then.

Trigs
29-06-2010, 09:51 PM
http://totalbasketball.herobo.com/test/speechgen.phps

nickyp88
29-06-2010, 09:53 PM
I want the GD imaging code. Not the habboemotion hotlink.

Trigs
29-06-2010, 10:02 PM
You just told me it was perfect a few posts ago.

I'm not going to code the whole thing for you from scratch.

nickyp88
29-06-2010, 10:06 PM
you aleady gave me the GD code. I just need to know where to put the form on it

Trigs
30-06-2010, 01:47 AM
It doesn't work like that.

If you don't know where to put the form you shouldn't really be pursuing PHP. Learn HTML (the basics at least) before trying something using PHP GD.

lolwut
03-07-2010, 04:57 PM
you aleady gave me the GD code. I just need to know where to put the form on it

STOP BEING AN ********.

(sorry i'm on my man period today)

Want to hide these adverts? Register an account for free!