I'm having trouble getting my head around this. I generate an image but I want to show it on an HTML page. So far I have something like this:
Code: Select all
<form method="post" action="myapp.php">
<input type="text" name="name">
<input name="colour" type="radio" value="1">Red<br>
<input name="colour" type="radio" value="2">Blue<br>
<input name="colour" type="radio" value="3">Green<br>
<input type="submit" value="Submit" name="submit">
</form>
<?php
function display()
{
$textdata = $_POST["name"];
$colourdata = $_POST["colour"];
$image = new Imagick();
$image->newPseudoImage(500, 500, 'gradient:#3a7bd5-#3a6073');
$image->setImageFormat('png');
header('Content-type: image/png');
echo $image;
}
if(isset($_POST['submit']))
{
display();
}
?>
1. Stream it to a file using a separate image.php file, which is called a bit like this <img src="image.php">
2. Output it was base64
3. Write it to a file
I'm not really sure what is the best way, because I'm wondering if base64 and writing it to a file and then reading it have a bit more of a performance overhead than steaming it - but for the image.php I don't really know how if it's good practice to be trying to send parameters to a php function within an image (which I want to get next to set the text etc)
Any guidance would be appreciated.