Posted By

rizzn2k on 03/03/09


Tagged

php engine render nfo


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

xtheonex


NFO Render Engine


 / Published in: PHP
 

Let's you render your .nfo Files to PNG Images.

  1. <?php
  2. function output_nfo_image ($filename, $size) {
  3. $font_file = "C:/WINDOWS/Fonts/cour.ttf";
  4. $nfo_file_lines = file($filename);
  5. $width = 0;
  6. for($i = 0; $i < count($nfo_file_lines); $i++) {
  7. $box = imagettfbbox($size, 0, $font_file, $nfo_file_lines[$i]);
  8. $width = max($width, $box[2]);
  9. }
  10. $image = imagecreate($width, $size * (count($nfo_file_lines) + 1));
  11. $background_color = imagecolorallocate($image, 0, 0, 0);
  12. $text_color = imagecolorallocate($image, 255, 255, 255);
  13. for($i = 0; $i < count($nfo_file_lines); $i++) {
  14. imagettftext($image, $size, 0, 0, $size * ($i + 1), $text_color, $font_file, $nfo_file_lines[$i]);
  15. }
  16. header("Content-type: image/png");
  17. imagepng($image);
  18. imagedestroy($image);
  19. }
  20.  
  21. //Calls the function to render "myfile.nfo" in image size "10".
  22. output_nfo_image("myfile.nfo", 10);
  23. ?>

Report this snippet  

You need to login to post a comment.