Need a API-Text to Image PHP script

Bluscream

Retired Staff
Contributor
Joined
May 8, 2015
Messages
967
Reaction score
934
Points
211
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 :)
 

Kleberstoff

Knowledge Seeker
VIP
Joined
Dec 29, 2015
Messages
308
Reaction score
214
Points
158
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.
 

Norvik

Retired Staff
Contributor
Joined
Jul 18, 2015
Messages
635
Reaction score
588
Points
157
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 :)
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

Retired Staff
Contributor
Joined
May 8, 2015
Messages
967
Reaction score
934
Points
211
Thanks, i would prefer a png for transparency ♥
 

dedmen

TeamSpeak Developer
Contributor
Joined
Mar 28, 2016
Messages
530
Reaction score
584
Points
197
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($im, true);
    $background_color = imagecolorallocatealpha ($im, $bgr,$bgb,$bgg,$bga);        //RGB color background.
    imagefill ($im,0,0,$background_color);
       $text_color = imagecolorallocate($im, 0, 0, 0);
      
       $i = 0;
       putenv('GDFONTPATH=' . realpath('.'));
       foreach (explode("\n" , $text) as $value){
           imagettftext ($im , $fsize ,0, 0 , ($i * 16)+16, $text_color, dirname(__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
 

Bluscream

Retired Staff
Contributor
Joined
May 8, 2015
Messages
967
Reaction score
934
Points
211
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?
Any progress yet? I'm waiting so desperately for this :)
 
Top