All pastes #231244 Raw Edit

Anonyme

public text v1 · immutable
#231244 ·published 2006-10-31 18:25 UTC
rendered paste body
<?php
// Original by nap
// Caching by icez
//
// INSTALLATION:
//   mkdir cache
//   chmod a+w cache

header("Content-type: image/png");
    
define('CACHE_DIR', 'cache/');
$key = md5($_SERVER['REQUEST_URI']);
    
if (!file_exists(CACHE_DIR.$key.'.png')) {
    $_GET['string']        = stripslashes($_GET['string']);
    list($weight, $rgb, $font)    = explode(':',$_GET['typo']);
    if($weight > 100) die();
    list($r, $g, $b)        = explode(',',$rgb);
    $font            = 'font/'.$font.'.ttf';
    $argu            = imagettfbbox($weight, 0, $font, $_GET['string']);
    $im                = @imagecreate($argu[2] + 6, ($weight + ($weight * 30 / 42))) or die();
    $bg                = imagecolorallocatealpha($im, 255, 255, 255, 127);
    $fg                = imagecolorallocate($im, $r, $g, $b);

    imagettftext($im, $weight, 0, 2, $weight + 4, $fg, $font, $_GET['string']);
    imagepng($im);
    imagepng($im, CACHE_DIR.$key.'.png');
    imagedestroy($im);
} else {
    echo file_get_contents(CACHE_DIR.$key.'.png');
}
?>