yekis Posted December 17, 2007 Share Posted December 17, 2007 1. aside from the imagestring and imagettftext syntax that makes it possible for a string to become an image, it is possible for an image file (jpeg, gif, bmp, png, etc.) to be superimposed/overlapped into another image. See link below to get what i mean: http://us.share.geocities.com/yekis/jpegformtojpeg.jpg 2. Currently i have the following html and php code. After i input the html code for uploading the picture, <input name="file" type="file" id="file"> i just don't know the code for displaying the uploaded picture and overlapping it from a given image GIVEN IMAGE: background.png (e.g) $im = imagecreatefrompng("background.png"); ----------------------------------------------------- my current html code (workingscript7.html) <html> <head> <SCRIPT LANGUAGE="JavaScript"><!-- // --><![CDATA[ function textCounter(field, countfield, maxlimit) { if (field.value.length > maxlimit) // if too long...trim it! field.value = field.value.substring(0, maxlimit); else countfield.value = maxlimit - field.value.length; } // ]]></script> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head> <body> <table width="200" border="0"> <tr> <td><span class="style1"><strong><font size="2" face="Arial, Helvetica, sans-serif"><strong> </strong></font></strong></span> <form name="ff" action="redirection7.php" method="post"> <table width="436" border="0"> <tr> <td width="202"></td> <td width="224"></td> </tr> <tr> <td><strong><font size="2" face="Arial, Helvetica, sans-serif"><strong> <font size="2" face="Arial, Helvetica, sans-serif"><strong> </strong></font> </strong></font></strong><span class="style3">First Name of Seller</span></td> <td><input name="text" type="text" size="25" maxlength="14"></td> </tr> <tr> <td><p><strong><font size="2" face="Arial, Helvetica, sans-serif"><strong> <font size="2" face="Arial, Helvetica, sans-serif"><strong> </strong></font> <span class="style3"> </span></strong></font></strong><span class="style3">Contact Number</span></p></td> <td><label> <input name="contact" type="text" id="contact" value="091XXXXXXXX" size="25" maxlength="12"></label></td> </tr> <tr> <td><strong><font size="2" face="Arial, Helvetica, sans-serif"><strong> <font size="2" face="Arial, Helvetica, sans-serif"><strong> </strong></font> </strong></font></strong><span class="style3">Product Name</span></td> <td><label> <input name="product" type="text" id="product" size="25" maxlength="25"></label></td> </tr> <tr> <td><strong><font size="2" face="Arial, Helvetica, sans-serif"><strong> <font size="2" face="Arial, Helvetica, sans-serif"><strong> </strong></font> </strong></font></strong><span class="style3">Description</span></td> <td><label><font size="1" face="arial, helvetica, sans-serif"> ( You may enter up to 100 characters. )<br> <textarea name="description" id="description" wrap=physical cols=19 rows=4 onKeyDown="textCounter(this.form.description,this.form.remLen,100);" onKeyUp="textCounter(this.form.description,this.form.remLen,100);"></textarea> <br> <input readonly type=text name=remLen size=3 maxlength=3 value="100"> characters left</font></label></td> </tr> <tr> <td><strong><font size="2" face="Arial, Helvetica, sans-serif"><strong> <font size="2" face="Arial, Helvetica, sans-serif"><strong> </strong></font> </strong></font></strong><span class="style3">Price (PHP)</span></td> <td><label> <input name="price" type="text" id="price" size="25" maxlength="7"></label></td> </tr> <tr> <td> </td> <td><center><input name="submit" type="submit" value="View"> <input type="submit" name="submit" value="Download"></center></td> </tr> </table> </form> </td> <td><br> <br></td> </tr> </table> <p> <p align="center" class="style3"> </p> </body> </html> 2. my current php code (redirection7.php) <?php ### when the user presses the submti button then use gd functions... if(isset($_POST) && !empty($_POST) && $_POST['submit'] != 'Download') { $image = genImage(); header('HTTP/1.0 200 Ok'); header('Content-Type: image/png'); header('Content-Length: ' . strlen($image)); header('Content-Disposition: inline; filename=' . $name); print $image; } elseif($_POST['submit'] == 'Download') { $image = genImage(); header('Content-Type: image/png'); header('Content-Length: ' . strlen($image)); header('Content-Disposition: attachment; filename=' . $name); print $image; } else { header('Content-Type: text/plain'); echo 'No posted information '; } function genImage() { $name = $_POST['text']; # get value for name... $contact = $_POST['contact']; # get value for contact... $product = $_POST['product']; # get value for product... $price = $_POST['price']; # get value for price... $description = $_POST['description']; # get value for description... $im = imagecreatefrompng("background.png"); $white = imagecolorallocate($im, 255, 255, 255); #loads font $font = "ariblk.ttf"; // imageloadfont($font); # this is for product imagettftext($im, 18, 0, 10, 40, $white, $font, $product); # this is for description... $description = wordwrap($description, 15, "\n", true); imagettftext($im, 18, 0, 10, 90, $white, $font, $description); # this is for name imagettftext($im, 14, 0, 300, 315, $white, $font, $name); # this is for contact number imagettftext($im, 14, 0, 300, 340, $white, $font, $contact); # this is for price imagettftext($im, 17, 0, 363, 88, $white, $font, $price); $name = time().'.png'; $path = './images/'.$name; ob_start(); imagepng($im); $image = ob_get_contents(); ob_end_clean(); imagedestroy($im); return $image; } ?> i have also attached background.png w/c was used in current codes [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.