Jump to content

CocaCola

Members
  • Posts

    5
  • Joined

  • Last visited

CocaCola's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi PaulRyan, Thanks i've been looking into imagegettext, but i'm really not sure how to convert what i have to this.
  2. Hi Q695, My script does the following : User inputs 5 details into text fields then hit's submit. This creates a image that's uneditable after it has been submitted. So i require to be able to change the font within the script itself before it being submitted. Hopefully this makes sense.
  3. Struggling to change font & font size. This is the code i'm using, and it works perfectly fine apart from i need to change the outputted font's but as it's joined to a image i can't do that with css after the image so need to do it before its processed but have no clue how? Please any help is appreciated. <?php // load the image from the file specified: $im = imagecreatefrompng("image.png"); // if there's an error, stop processing the page: if(!$im) { die(""); } // define some colours to use with the image $black = imagecolorallocate($im, 80, 77, 77); // get the width and the height of the image $width = imagesx($im); $height = imagesy($im); $textt = $_GET['textt']; $dealer = $_GET['dealer']; $purchase = $_GET['purchase']; $name = $_GET['name']; $address = $_GET['address']; $address1 = $_GET['address1']; // store the text we're going to write in $textt // calculate the left position of the text: $leftTextPos = ( $width - imagefontwidth($font)*strlen($textt) )/2; $leftTextPos = ( $width - imagefontwidth($font)*strlen($dealer) )/2; // finally, write the string: imagestring($im,$font,$leftTextPos-210,$height-295,$textt,$black); imagestring($im,$font,$leftTextPos-210,$height-165,$dealer,$black); imagestring($im,$font,$leftTextPos-200,$height-115,$purchase,$black); imagestring($im,$font,$leftTextPos-130,$height-70,$name,$black); imagestring($im,$font,$leftTextPos-100,$height-50,$address,$black); imagestring($im,$font,$leftTextPos-00,$height-50,$address1,$black); // output the image // tell the browser what we're sending it Header('Content-type: image/png'); // output the image as a png imagepng($im); // tidy up imagedestroy($im); ?>
  4. Hi DavidAM, Thanks for your post apprecaite it. I've been reading on there and maybe i'm not understanding correctly but still seem to be having trouble. I'm using this <?php // load the image from the file specified: $im = imagecreatefrompng("warranty.png"); // if there's an error, stop processing the page: if(!$im) { die(""); } // define some colours to use with the image $black = imagecolorallocate($im, 80, 77, 77); // get the width and the height of the image $width = imagesx($im); $height = imagesy($im); // draw a black rectangle across the bottom, say, 20 pixels of the image: //imagefilledrectangle($im, 0, ($height-20) , $width, $height, $black); // now we want to write in the centre of the rectangle: $font_size = 18; $text = $_GET['text']; // store the text we're going to write in $text putenv('GDFONTPATH=' . realpath('cour.ttf')); // Name the font to be used (note the lack of the .ttf extension) $font = 'cour'; // calculate the left position of the text: $leftTextPos = ( $width - imagefontwidth($font)*strlen($text) )/2; // finally, write the string: imagestring($im,$font,$leftTextPos-210, $height-295,$text,$black); // output the image // tell the browser what we're sending it Header('Content-type: image/png'); // output the image as a png imagepng($im); // tidy up imagedestroy($im); ?> But can't seem to be able to change the font face on the finished output.png Any help
  5. Hi guys, As you can tell I'm fresh and new here but I'm trying to learn PHP to do a few things that i need so i would truely appreciate any help or information and advice that i receive. Basically what I'm trying to do is have two pages First page consists of 5 text input boxes that have the fields. Age Name Telephone Skype Address Email once these were filled out and a user hit Submit they would be generated onto a image for them to download. I'm having a few problems and searched the forum and did come across a thread that kind of explained to similar what i was trying to do but there wasn't much of a positive outcome or fix. These input boxes need to be located at certain points of the image and not just anywhere. The first page where somebody would imput there data is : <body> <form name="code_input" enctype="application/x-www-form-urlencoded" method="GET" action="getcard.php"> Age: <input class="text" type="text" size="24" name="age" value="" /> <br> Name: <input class="text" type="text" size="24" name="name" value="" /> <br> Telephone: <input class="text" type="text" size="24" name="telephone" value="" /> <br> Skype: <input class="text" type="text" size="24" name="skype" value="" /> <br> Address: <input class="text" type="text" size="24" name="address" value="" /> <br> Email: <input class="text" type="text" size="24" name="email" value="" /> <br> <input type="submit" name="submit" value="submit"> </form> </body> </html> But i'm really not sure how i go about working 'getcard.php' page on the thread i found in the search this was something somebody had posted to generate text from a input page to a image. <?php // Load the stamp and the photo to apply the watermark to $im = imagecreatefrompng('image.png'); // Set the content-type header('Content-type: image/png'); header("Content-Description: File Transfer"); header("Content-Disposition: attachment; filename=coupon.png"); header("Content-Transfer-Encoding: binary"); $coupon_code = "empty code"; if(isSet($_GET['coupon_code'])) { $coupon_code = $_GET['coupon_code']; } // Replace path by your own font path $font = 'arial.ttf'; $black = ImageColorAllocate ($im, 0, 0, 0); $grey = ImageColorAllocate ($im, 128, 128, 128); // Add some shadow to the text imagettftext($im, 20, 0, 647, 351, $grey, $font, $coupon_code); // Add the text imagettftext($im, 20, 0, 646, 350, $black, $font, $coupon_code); // Using imagepng() results in clearer text compared with imagejpeg() imagepng($im); ?> As i'm new I'm honestly not sure which direction to go now, I don't just want to copy and paste i would prefer to learn how but struggling to find any real helpful information in regarding what i require and how to do it. Any advice/help/examples would truely be appreciated. thanks alot
×
×
  • 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.