Question Need a API-Text to Image PHP script

Discussion in 'Linux' started by Bluscream, Dec 13, 2016.

  1. Bluscream

    Bluscream Contributing Member

    Hey guys, i was thinking of this a lot of times now and most of you seem pretty familiar with PHP and webservers so i decided to explain my request here as good as possible:

    How it should work:
    1. I copy the script template and rewrite it to use the API i need right now ( In this example the github API )
    2. I upload it to my webserver at for example https://example.com/banner/github.php
    3. Anyone can request https://example.com/banner/github.p...://example.com/banner/image.php&color=#ffffff
    4. It returns the text returned by the api in a white color on the image.
    It would be awesome if someone could point me to it if it already exists :)
     
  2. Kleberstoff

    Kleberstoff Knowledge Seeker Member of the Month

    So basicly, you want a script that outputs the API's output to a Image and the Image Color can be changed by a get-request?
    Just need confirmation that i understood it correctly.
     
    Bluscream likes this.
  3. Ridicc

    Ridicc Moderator

    I'm gonna work on it as soon as I'm at home. It's not that hard, do you want it to be a png or a jpg file?
     
    Bluscream and Kleberstoff like this.
  4. Bluscream

    Bluscream Contributing Member

    Thanks, i would prefer a png for transparency ♥
     
  5. dedmen

    dedmen TS3 Dev-Team Contributor

    PHP:
    function makeImageF($text$W=800$fsize=13,$bgr=1,$bgb=1,$bgg=1,$bga=127){
          
    $H substr_count ($text,"\n") * 20;
           
    //$H = 50;
          
        
    $im imagecreatetruecolor($W$H);
           
    imagesavealpha($imtrue);
        
    $background_color imagecolorallocatealpha ($im$bgr,$bgb,$bgg,$bga);        //RGB color background.
        
    imagefill ($im,0,0,$background_color);
           
    $text_color imagecolorallocate($im000);
          
           
    $i 0;
           
    putenv('GDFONTPATH=' realpath('.'));
           foreach (
    explode("\n" $text) as $value){
               
    imagettftext ($im $fsize ,0, ($i 16)+16$text_colordirname(__FILE__) . '/cour.ttf',$value);
               
    //array imagettftext ( resource $im , int $size , int $angle , int $x , int $y , int $col , string $fontfile , string $text )
               // imagestring($im, 1, 0, $i * 20, $value,$text_color);
               
    $i+=1;
           }
              
              
      
        
        
    header('Content-type: image/png');//jpeg
        //imagejpeg($im);
        
    imagepng($im);
        
    imagedestroy($im);
        return;
    }
    copy pasta from my dynamic teamspeak banner thingy
     
  6. Bluscream

    Bluscream Contributing Member

    Any progress yet? I'm waiting so desperately for this :)
     
  7. Ridicc

    Ridicc Moderator

    Kinda forgot it since I'm pretty busy. I'm sorry but it could take quite some time.
     
    Bluscream likes this.

Share This Page