Return to Snippet

Revision: 12136
at March 3, 2009 10:13 by rizzn2k


Initial Code
<?php
function output_nfo_image ($filename, $size) {
    $font_file = "C:/WINDOWS/Fonts/cour.ttf";
    $nfo_file_lines = file($filename);
    $width = 0;
    for($i = 0; $i < count($nfo_file_lines); $i++) {
        $box = imagettfbbox($size, 0, $font_file, $nfo_file_lines[$i]);
        $width = max($width, $box[2]);
    }
    $image = imagecreate($width, $size * (count($nfo_file_lines) + 1));
    $background_color = imagecolorallocate($image, 0, 0, 0);
    $text_color = imagecolorallocate($image, 255, 255, 255);
    for($i = 0; $i < count($nfo_file_lines); $i++) {
        imagettftext($image, $size, 0, 0, $size * ($i + 1), $text_color, $font_file, $nfo_file_lines[$i]);
    }
    header("Content-type: image/png");
    imagepng($image);
    imagedestroy($image);
}

//Calls the function to render "myfile.nfo" in image size "10".
output_nfo_image("myfile.nfo", 10);
?>

Initial URL


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

Initial Title
NFO Render Engine

Initial Tags
php

Initial Language
PHP