html - Trying to create a png file from txt input PHP -


i'm learning code , making little project myself. i'm trying project out html5 , php. here want do:

i want user input info, name, address, number, ect. want grab info , somehow place .png file can save picture. have code grab text, i'm stuck on next part.

here part of code used info:

$first = $_request['first']; $last = $_request['last']; $email = $_request['email']; $address = $_request['address']; $city = $_request['city']; 

i hope question makes sense.

this done using php gd library.

you need png image start with. can choose example 100 x 100 canvas.png nothing white on (so can read black text on it).

also find font write text with. save in same directory script.

<?php     // fetch text write     $first = $_request['first'];     $last = $_request['last'];     $email = $_request['email'];     $address = $_request['address'];     $city = $_request['city'];      header('content-type: image/png');      $canvas = imagecreatefrompng('canvas.png'); // let's suppose canvas.png 100x100 pure white png      $black = imagecolorallocate($canvas, 0, 0, 0); // create color object (choosing black white canvas!)      $font_path = './myfont.ttf'; // select font      // imagettftext (resource $image , float $size , float $angle , int $x , int $y , int $color , string $fontfile , string $text )      imagettftext($canvas, 10, 0, 10, 10, $black, $font_path, $first); // place text on canvas     imagettftext($canvas, 10, 0, 10, 25, $black, $font_path, $last); // place text on canvas     imagettftext($canvas, 10, 0, 10, 40, $black, $font_path, $email); // place text on canvas     imagettftext($canvas, 10, 0, 10, 55, $black, $font_path, $address); // place text on canvas     imagettftext($canvas, 10, 0, 10, 60, $black, $font_path, $city); // place text on canvas      imagepng($canvas); // send image browser      imagedestroy($canvas); // clear memory ?>  

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -