I got this script
<?php
Header ("Content-type: image/png");
$img_handle = imageCreateFromPNG("banner.png");
$color = ImageColorAllocate ($img_handle, 100, 100, 100);
ImageString ($img_handle, 3, 10, 9, "TESTING", $color);
ImagePng ($img_handle);
ImageDestroy ($img_handle);
?>
how can I change the script like that people can enter a text in a input box and the text will be showed on the dynamic image???
Copyright © 2024 Q2A.MX - All rights reserved.
Answers & Comments
Verified answer
Yes, you can do this.
Presumably , there is an input to select image also?
You need an extra input first for the text, call it show.
<form action=myURL>
<input type=text name=image>
<input type=text name=show>
</form>
So previously you would respond to the query
myURL?image=myimg by returning an image.
Now the query is
myURL?image=myimg&show=mytext
This time, in your PHP, if you see show=mytext
then return this HTML using Content-type: text/html :
<div style="position:absolute; z-index:0;">
<img src="myURL?image=myimg"/>
</div>
<div style="position:absolute; left:0px; top:0px; z-index:1;">
<font>mytext</font>
</div>
The trick is to make the src of the <img>
tag the same as your dynamic image.
This floats the text on top of your image by using z-index.
Adjust the left and top numbers to position your text.
And you can position the divs wherever you like on the page.
Hope this helps.
The image is created on the server. The text is entered on the client machine.
So you need to pass the input data to the server and then have the image displayed.