GD/PHP Add text from form / Transparent Background

Asked

Viewed 35 times

0

<?php
    $image = imagecreatetruecolor(100, 100);

    //Fundo Transparente
    imagealphablending($image, false);
    $transparency = imagecolorallocatealpha($image, 0, 0, 0, 127);
    imagefill($image, 0, 0, $transparency);
    imagesavealpha($image, true);

    //Aproveitando
    $black = imagecolorallocate($image, 255, 174, 0);
    imagefilledrectangle($image, 25, 25, 75, 75, $black);

    header('Content-Type: image/png');
    imagepng($image);
?>

I want to add a form with only one input field, when clicking the Submit button generate an image with transparent background with the content that wrote in the input field.

Can someone help me do?

1 answer

0

here’s an example:

<form action="proccessImage.php" method="post">
    Input: <input type="text" name="input1"><br>
    <input type="submit">
</form>

When you click on the button a post request will be made to the file proccessImage.php, where you can then add your code to process the image

you can also get the Input value by doing the following:

$input1 = $_POST['input1'];

Browser other questions tagged

You are not signed in. Login or sign up in order to post.