It is currently Mon Jan 18, 2021 1:47 am

All times are UTC

Forum rules

Please click here to view the forum rules

Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Dynamic image problem - why doesnt it save as a png?
PostPosted: Wed Jun 21, 2006 1:31 am 

Joined: Mon Jun 19, 2006 2:56 am
Posts: 3
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:

$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($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');




And here is the html 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 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>
<input type="text" maxlength="22" name="add_text">

<input type="submit" value="submit">

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. :cry:


Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ]  Moderators: fhmagic, KJ, Support Team, Moderators

All times are UTC

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
100WebSpace © 2011