Jump to content

_SAi_

Members
  • Posts

    19
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

_SAi_'s Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. So, does this mean that what I am trying to do is not possible? ???
  2. Bueller? Bueller? Anyone have any more ideas? Would I be able to replace the \n with something and explode for that?
  3. Everything is the same... all I did was copy the lines of code and change the "pp" to "\n" and remark the other lines of code. If someone could take this code and test for themselves that would be great! form: <html> <form name="form1" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <?php if(!empty($_GET['text1'])) { $img = '_2splitb.php?text1=' . $_GET['text1']; } else { $img = '_2splitb.php'; } echo "<img src=\"$img\" />"; echo "<br><br>"; echo $_GET['text1']; echo "<br><br>"; print_r(explode("\n", $_GET['text1'])); //print_r(explode("pp", $_GET['text1'])); ?> <p> <br> <br> <textarea name="text1" cols="50" id="text1"><?php echo($_GET['text1']); ?></textarea> </p> <p> <input type="submit" name="Submit" value="Submit"> </p> </form> </html> Image Creation: <?php header("Content-type: image/png"); if (!isset($_GET["text1"])) $msg = "multi line centered text"; else $msg = $_GET["text1"]; $text = explode("\n", $msg); //$text = explode("pp", $msg); $width=500; $line_height=30; $height=sizeof($text)*$line_height; // Create the image $im = imagecreatetruecolor($width, $height); // Create some colors $white = imagecolorallocate($im, 255, 255, 255); $grey = imagecolorallocate($im, 225, 225, 225); $blue = imagecolorallocate($im, 0, 62, 126); imagefilledrectangle($im, 0, 0, $width, $height, $white); // Replace path by your own font path $font = 'arial.ttf'; for($i=0;$i<=sizeof($text);$i++) { //Center the text $size = imagettfbbox(20, 0, $font, $text[$i]); $long_text = $size[2]+$size[0]; $posx=($width-$long_text)/2; // Add the text imagettftext($im, 20, 0, $posx, $line_height+$line_height*$i, $blue, $font, $text[$i]); } imagepng($im); imagedestroy($im); echo "<br><br>" + $text[1]; ?> Thanks!
  4. Things still aren't creating the image the way it should... If I explode for say "pp" and enter happybirthday... the array shows correctly and the image shows it broken into two lines with the pp gone. Now, I'm not familiar with the explode function so I don't know if that's what it is supposed to do. On the other hand, if I put back in my "\n" into the explode function, all of a sudden things stop working. The "pp" Form: <html> <form name="form1" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <?php if(!empty($_GET['text1'])) { $img = '_2splitb-pp.php?text1=' . $_GET['text1']; } else { $img = '_2splitb-pp.php'; } echo "<img src=\"$img\" />"; echo "<br><br>"; echo $_GET['text1']; echo "<br><br>"; print_r(explode("pp", $_GET['text1'])); ?> <p> <br> <br> <textarea name="text1" cols="50" id="text1"><?php echo($_GET['text1']); ?></textarea> </p> <p> <input type="submit" name="Submit" value="Submit"> </p> </form> </html> The "pp" Image Creation: <?php header("Content-type: image/png"); if (!isset($_GET["text1"])) $msg = "multi line centered text"; else $msg = $_GET["text1"]; $text = explode("pp", $msg); $width=500; $line_height=30; $height=sizeof($text)*$line_height; // Create the image $im = imagecreatetruecolor($width, $height); // Create some colors $white = imagecolorallocate($im, 255, 255, 255); $grey = imagecolorallocate($im, 225, 225, 225); $blue = imagecolorallocate($im, 0, 62, 126); imagefilledrectangle($im, 0, 0, $width, $height, $white); // Replace path by your own font path $font = 'arial.ttf'; for($i=0;$i<=sizeof($text);$i++) { //Center the text $size = imagettfbbox(20, 0, $font, $text[$i]); $long_text = $size[2]+$size[0]; $posx=($width-$long_text)/2; // Add the text imagettftext($im, 20, 0, $posx, $line_height+$line_height*$i, $blue, $font, $text[$i]); } imagepng($im); imagedestroy($im); echo "<br><br>" + $text[1]; ?> Here is the "pp" example: http://68.147.219.153/fontpreview/test/close/index-pp.php?text1=happybirthday&Submit=Submit Here is the same program with the "pp" replaced with "\n": http://68.147.219.153/fontpreview/test/close/index.php?text1=happy%0D%0Abirthday&Submit=Submit The only things changed are the "pp" replaced with the "\n". So, how come the array shows two separate words but the image still does not break it into the two lines? I am soooo confused!
  5. also, on the _GET files I did the echo and looked at the source... got this <html> <form name="form1" method="get" action="index.php"> <img src="_2splitb.php?text1=this is" /><br><br>this is <p> <br> <br> <textarea name="text1" cols="50" id="text1">this is</textarea> </p> <p> <input type="submit" name="Submit" value="Submit"> </p> </form> </html> It doesn't show me anything special. _GET: http://68.147.219.153/fontpreview/test/close/ _POST http://68.147.219.153/fontpreview/test/close/index-post.php
  6. I changed all of my _GET to _POST and changed the form method="post". All I see in the image is my default text. Am I missing something? What is the proper way to look for a \n... with " " or with ' '? Again if I use '\n' my lines are split at every n rather than my intended \n. $nl = '\n'; if (!isset($_POST["text1"])) $msg = "multi line centered text"; else $msg = $_POST["text1"]; $text = split($nl, $msg); and <form name="form1" method="post" action="index.php"> <?php if(!empty($_POST['text1'])) { $img = '_2splitb.php?text1=' . $_POST['text1']; } else { $img = '_2splitb.php'; } echo "<img src=\"$img\" />"; echo "<br><br>"; echo $_POST['text1']; ?> http://68.147.219.153/fontpreview/test/close/index.php
  7. ok, I was not able to get a POST instead of a GET. It just showed my default text eventhough when I echoed the variable it showed the new text. I tried changing from \n to %0a and still the same.... only a single line of text. $nl = '%0a'; if (!isset($_GET["text1"])) $msg = "multi line centered text"; else $msg = $_GET["text1"]; $text = split($nl, $msg); Is there any way to show all of the characters in the string so I know exactly what I need to split by? As is it now I get a space where a carriage return is. http://68.147.219.153/fontpreview/test/close/
  8. Thanks, but that still doesn't work for me. //$nl = '\n'; if (!isset($_GET["text1"])) $msg = "multi line centered text"; else $msg = $_GET["text1"]; //$text = split($nl, $msg); $text = explode("\n", $msg); Everything is back onto a single line.
  9. I tried replacing with '\n' but that didn't work. It still puts it all onto one line... except the default text.. it breaks that up kinda strangely. $nl = '\n'; if (!isset($_GET["text1"])) $msg = "multi line centered text"; else $msg = $_GET["text1"]; $text = split($nl, $msg); Any other suggestions?
  10. Hello, For the life of me, I am not able to detect a newline entered into a textarea. I want to take in a multi-line phrase and split into seperate lines, then output an image broken into thet proper lines. No matter what I try i cannot get it to work. <?php header("Content-type: image/png"); $nl = "\r\n"; if (!isset($_GET["text1"])) $msg = "sample text in here are you ready?!!"; else $msg = $_GET["text1"]; $text = split($nl, $msg); $width=500; $line_height=30; $height=sizeof($text)*$line_height; // Create the image $im = imagecreatetruecolor($width, $height); // Create some colors $white = imagecolorallocate($im, 255, 255, 255); $grey = imagecolorallocate($im, 225, 225, 225); $blue = imagecolorallocate($im, 0, 62, 126); imagefilledrectangle($im, 0, 0, $width, $height, $white); // Replace path by your own font path $font = 'arial.ttf'; for($i=0;$i<=sizeof($text);$i++) { //Center the text $size = imagettfbbox(20, 0, $font, $text[$i]); $long_text = $size[2]+$size[0]; $posx=($width-$long_text)/2; // Add the text imagettftext($im, 20, 0, $posx, $line_height+$line_height*$i, $blue, $font, $text[$i]); } imagepng($im); imagedestroy($im); echo "<br><br>" + $text[1]; ?> As it works now, the lines are not found and it all outputs to a single line. Here is my non-working page so far... http://68.147.219.153/fontpreview/test/close/ Thanks for any help!!
  11. Thanks, But this appears to load a new page.  I was hoping to add it to the existing page.  Is there a way to do that?
  12. Hello, I have a bit of html I would like to link to instead of having my page load it: [code] <div id="plugin" onmousedown="HSVslide('drag','plugin',event)" style="TOP: 240px; LEFT: 430px; Z-INDEX: 20;"> <div id="plugHEX" onmousedown="stop=0; setTimeout('stop=1',100);">F1FFCC</div> <div id="plugCLOSE">Background Colour</div><br> <div id="SV" onmousedown="HSVslide('SVslide','plugin',event)" title="Saturation + Value"> <div id="SVslide" style="TOP: -4px; LEFT: -4px;"><br /></div> </div> <form id="H" onmousedown="HSVslide('Hslide','plugin',event)" title="Hue">   <div id="Hslide" style="TOP: -7px; LEFT: -8px;"><br /></div>   <div id="Hmodel"></div> </form> </div> [/code] I would like to link to it so I tried this without anything happening. In my <head> section I created a function: [code] <script type="text/javascript"> function callBGhex() { document.write('<div id="plugin" onmousedown="HSVslide('drag','plugin',event)" style="TOP: 140px; LEFT: 430px; Z-INDEX: 20;">'); document.write('<div id="plugHEX" onmousedown="stop=0; setTimeout('stop=1',100);">F1FFCC</div><div id="plugCLOSE" onmousedown="toggle('plugin')">X</div><br>'); document.write('<div id="SV" onmousedown="HSVslide('SVslide','plugin',event)" title="Saturation + Value">'); document.write('<div id="SVslide" style="TOP: -4px; LEFT: -4px;"><br /></div>'); document.write('</div>'); document.write('<form id="H" onmousedown="HSVslide('Hslide','plugin',event)" title="Hue">'); document.write('<div id="Hslide" style="TOP: -7px; LEFT: -8px;"><br /></div>'); document.write('<div id="Hmodel"></div>'); document.write('</form>'); document.write('</div>'); } </script> [/code] And then for my link in the <body> section I used: [code] <a href="javascript:onMouseUp=callBGhex();">Show IT!!</a> [/code] Am I forgetting something or is something wrong? Thank you!
  13. Ok, this is what I have tried, but it doesn't appear to be working. Any Ideas?? [code] class textPNG { var $font = 'ttf/Script/Amazone.ttf'; //default font. directory relative to script directory. var $msg = "this is a sample of using dynamic fonts with PHP"; // default text to display. var $size = 25; var $rot = 0; // rotation in degrees. var $pad = 15; // padding. var $transparent = 0; // transparency set to on. var $red = 0; // black text... var $grn = 0; var $blu = 0; var $bg_red = 255; // on white background. var $bg_grn = 255; var $bg_blu = 255; var $hex = 'FFFFFF'; var $alignment = 'Left'; function draw() { $width = 0; $height = 0; $offset_x = 0; $offset_y = 0; $bounds = array(); $image = ""; // determine font height. $bounds = ImageTTFBBox($this->size, $this->rot, $this->font, "W"); if ($this->rot < 0) { $font_height = abs($bounds[7]-$bounds[1]); } else if ($this->rot > 0) { $font_height = abs($bounds[1]-$bounds[7]); } else { $font_height = abs($bounds[7]-$bounds[1]); } // determine bounding box. $bounds = ImageTTFBBox($this->size, $this->rot, $this->font, $this->msg); if ($this->rot < 0) { $width = abs($bounds[4]-$bounds[0]); $height = abs($bounds[3]-$bounds[7]); $offset_y = $font_height; $offset_x = 0; } else if ($this->rot > 0) { $width = abs($bounds[2]-$bounds[6]); $height = abs($bounds[1]-$bounds[5]); $offset_y = abs($bounds[7]-$bounds[5])+$font_height; $offset_x = abs($bounds[0]-$bounds[6]); } else { $width = abs($bounds[4]-$bounds[6]); $height = abs($bounds[7]-$bounds[1]); $offset_y = $font_height;; // $offset_x = 0; if ($this->alignment == "Right") $offset_x -= $width; else if ($this->alignment == "Centre") $offset_x -= $width / 2; else $offset_x = 0; } //else $image = imagecreate($width+($this->pad*2)+1,$height+($this->pad*2)+1); $background = ImageColorAllocate($image, $this->bg_red, $this->bg_grn, $this->bg_blu); $foreground = ImageColorAllocate($image, $this->red, $this->grn, $this->blu); if ($this->transparent) ImageColorTransparent($image, $background); ImageInterlace($image, false); // render it. ImageTTFText($image, $this->size, $this->rot, $offset_x+$this->pad, $offset_y+$this->pad, $foreground, $this->font, $this->msg); // output PNG object. imagePNG($image); } //function draw } //class [/code] Thanks!
  14. Thanks, I am still very new to php.  Is there a way to integrate that into what I currently have? [code] class textPNG { var $font = 'ttf/Script/Amazone.ttf'; //default font. directory relative to script directory. var $msg = "this is a sample of using dynamic fonts with PHP"; // default text to display. var $size = 25; var $rot = 0; // rotation in degrees. var $pad = 15; // padding. var $transparent = 0; // transparency set to on. var $red = 0; // black text... var $grn = 0; var $blu = 0; var $bg_red = 255; // on white background. var $bg_grn = 255; var $bg_blu = 255; var $hex = 'FFFFFF'; function draw() { $width = 0; $height = 0; $offset_x = 0; $offset_y = 0; $bounds = array(); $image = ""; // determine font height. $bounds = ImageTTFBBox($this->size, $this->rot, $this->font, "W"); if ($this->rot < 0) { $font_height = abs($bounds[7]-$bounds[1]); } else if ($this->rot > 0) { $font_height = abs($bounds[1]-$bounds[7]); } else { $font_height = abs($bounds[7]-$bounds[1]); } // determine bounding box. $bounds = ImageTTFBBox($this->size, $this->rot, $this->font, $this->msg); if ($this->rot < 0) { $width = abs($bounds[4]-$bounds[0]); $height = abs($bounds[3]-$bounds[7]); $offset_y = $font_height; $offset_x = 0; } else if ($this->rot > 0) { $width = abs($bounds[2]-$bounds[6]); $height = abs($bounds[1]-$bounds[5]); $offset_y = abs($bounds[7]-$bounds[5])+$font_height; $offset_x = abs($bounds[0]-$bounds[6]); } else { $width = abs($bounds[4]-$bounds[6]); $height = abs($bounds[7]-$bounds[1]); $offset_y = $font_height;; $offset_x = 0; } $image = imagecreate($width+($this->pad*2)+1,$height+($this->pad*2)+1); $background = ImageColorAllocate($image, $this->bg_red, $this->bg_grn, $this->bg_blu); $foreground = ImageColorAllocate($image, $this->red, $this->grn, $this->blu); if ($this->transparent) ImageColorTransparent($image, $background); ImageInterlace($image, false); // render it. ImageTTFText($image, $this->size, $this->rot, $offset_x+$this->pad, $offset_y+$this->pad, $foreground, $this->font, $this->msg); // output PNG object. imagePNG($image); } //function draw } //class [/code] Many Thanks!
  15. Hi, Is there a way to specify the justification of text using the imagettftext function?  IF so, how would I go about aligning my multi line text left,  right or center? Thanks!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.