0
Hello.
I want to create a form with one input field and the other as Submit.
When you write something in the input field and click the Submit button an image will be generated through the PHP GD library. But the problem is, I don’t know how I can do this, I’ve researched several forums and read several articles on, but I can’t at all.
HTML CODE
<form action="" method="get">
<input name="nome" type="text" placeholder="Texto a ser Gerado" size="100"/>
<input type="submit" value="Criar Imagem"/>
PHP CODE
<?php
//Define o header como sendo de imagem
header("Content-type: image/png");
// Definições
$preto = imagecolorallocate($i, 0,0,0); #Cor do texto; "cor preta"
$texto = "Exemplo"; #Texto a ser escrito
$fonte = "trebuc.ttf"; #Fonte que será utilizada
//Escreve na imagem
imagettftext($i, 32, 0, 160,360, $preto, $fonte, $texto);
//Gera a imagem na tela
imagejpeg($i);
//Destroi a imagem para liberar memória
imagedestroy($i);
?>
Please give me a solution to my problem, how can I fix it?
Thank you so much from the start.
I did everything as you said, but I did not get a result with the code. Typing something in the input field and clicking the Ubmit button generates something like this. i.imgur.com/pnqNppo.png - But it does not generate the image with the text you insert in the input field, I hope you help. Thanks in advance.
– TruX
I’ll check again.
– mcamara
@Trux what you are getting in the $i variable ?
– mcamara
You need to upload an initial image for this, $i = imagecreatefromjpeg('imagem_initial.jpg');
– mcamara