JSON yanıt ile görüntü dönüştürme metin

0 Cevap php

i have made an application to convert text into image and it working out fine,now i am using JSON for conversion,it also working but except only two fields font and fontsize.....why i dont know, my codes are given below...please help me , is there any better way? //

img.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">

<head>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>excoflare</title>
</head>
<div>
<form action="img.php" method="post"><b>enter your text here:</b><br/>
<textarea id="text" name="text" style=" background-color:inherit" cols="50" rows="10"></textarea><br/><br/>


    </div><br/>
<div>
    <tr >
        <td >Font Size:</td> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
        <input type="text" name="size" id="size">

</tr>
    </div><br/>
<div>
    <td> Color: </td> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;
<input type="text" name="color" id="color">

</tr>

</div><br/>
<div>
    <td>Font: </td>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
    <input type="text" id="font" name="font">
</div><br/>


    <div>
        <td>Height: </td>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;

        <input type="text" id="height" name="height">


    </td><br/><br/>
    <td>Width:</td>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 

    <input type="text" id="width" name="width">
    </div><br/>
   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; <input type="submit" value="click here" name="submit">
</form>
</body>
</html>

img.php

<?php

        require_once 'JSON/JSON.php';
        header('Content-type: application/json');
        header ("Content-type: image/png");
        $text =$_REQUEST['text'];
        $text=json_encode($text);
        $path="C:\wamp\www\image";
        $height=$_REQUEST['height'];
        $width=$_REQUEST['width'];
        define("WIDTH", $width);
        json_encode(WIDTH);
        define("HEIGHT",  $height);
        json_encode(HEIGHT);
        $img = imagecreate(WIDTH, HEIGHT);
        imagesavealpha($img, true);
        $trans_colour = imagecolorallocatealpha($img, 0, 0, 0, 127);
        imagefill($img, 0, 0, $trans_colour);

        $getcolor=$_REQUEST['color'];

        switch($getcolor) {
                case 'red':
            $red = imagecolorallocate($img, 223, 14, 91);
                        $color=json_encode($red);
                        break;
        case 'white':
             $white = imagecolorallocate($img, 255, 255, 255);
                         $color=json_encode($white);
            break;
        case 'black':
             $black = imagecolorallocate($img, 0,0,0);
                         $color=json_encode($black);
            break;
        case 'grey':
            $grey = imagecolorallocate($img, 128, 128, 128);
                        $color=json_encode($grey);
            break;
               // default:
        //  break;
    }

        //$background_color = imagecolorallocate ($img, 25, 25, 25);
        $font = $_REQUEST['font'];
        //$font=json_encode($font);
        $fontsize =$_REQUEST['size'];
        //$fontsize=json_encode($fontsize);
        imagettftext($img, $fontsize, 0, 20, 20, $color, $font, $text);
        //Create image
        imagepng($img);
        imagepng($img,"$path/img.png");
        //destroy image
        ImageDestroy($img);
        //header ('Content-type: image/png');

?>

Şimdiden teşekkürler ..

0 Cevap