100 Web Space http://forum.100webspace.com/ |
|
Dynamic image problem - why doesnt it save as a png? http://forum.100webspace.com/viewtopic.php?f=5&t=4549 |
Page 1 of 1 |
Author: | labrat [ Wed Jun 21, 2006 1:31 am ] |
Post subject: | Dynamic image problem - why doesnt it save as a png? |
Hi all! I made a dynamic image generator that doesnt seem to work porperly. This dynamic image generator takes user input (i.e. choosing their desired font-type, image, and text). It generates the picture perfectly but when I saved it ("Save Picture As..."); it saves as a html file not a png file. Here is the PHP code: Code: <? $text = $_POST['add_text']; $font_type = $_POST['font_type']; $ul_image = $_POST['ul_image']; $im = imagecreatefrompng("$ul_image"); $width = imagesx($im); $height = imagesy($im); if(!$im) { die(""); } if($font_type == "image/font01.TTF"){ $font = 8; } else if($font_type == "image/font02.TTF"){ $font = 9; } else if($font_type == "image/font03.TTF"){ $font = 7; } $font_colour = ImageColorAllocate ($im, 255, 255, 255); $arr = imagettfbbox($font, 0, $font_type, $text); $lower_left = $arr[1]; $lower_right = $arr[2]; $var = $lower_left + $lower_right; $leftTextPos = ($width - $var) - 5; ImageTTFText($im, $font, 0, $leftTextPos, $height-5, $font_colour, $font_type, $text); Header('Content-type: image/png'); ImagePNG($im); imagedestroy($im); ?> And here is the html Code: Code: <form action="image.php" method="post">
<select name="ul_image"> <option value="image/image1.PNG">image1</option> <option value="image/image2.PNG">image2</option> <option value="image/image3.PNG">image3</option> <option value="image/image4.PNG">image4</option> <option value="image/image5.PNG">image5</option> </select> <select name="font_type"> <option value="image/font01.TTF">Font 01</option> <option value="image/font02.TTF">Font 02</option> <option value="image/font03.TTF">Font 03</option> </select> <input type="text" maxlength="22" name="add_text"> <input type="submit" value="submit"> </form> I can however, save a dynamic image as a png file if there are no user input. What did I do wrong? Is there anything missing or something out of place? Any sort of help would greatly be appreciated. Thanks. |
Page 1 of 1 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |