Exemplo n.º 1
0
# Remove potential http://
if (strpos($src, 'http://') === 0) {
    $src = preg_replace('/http:\\/\\/(.*?)\\//', '/', $src);
}
# See if it's cached
$cacheSrc = md5(implode($_GET));
$cacheSrc = 'cache/' . $cacheSrc . '.' . $ext;
if (file_exists($cacheSrc)) {
    try {
        $img = new abeautifulsite\SimpleImage($cacheSrc);
        $img->output();
    } catch (Exception $e) {
        echo $e->getMessage();
    }
    die;
}
# OLD SIMPLE IMAGE CODE
# Get the rest of the params TODO: Add all options: https://github.com/claviska/SimpleImage
$blur = isset($_GET['blur']) ? $_GET['blur'] : false;
# Run SimpleImage
try {
    $img = new abeautifulsite\SimpleImage($docRoot . $src);
    # TODO: Add all options
    if ($blur > 0) {
        $img->blur('gaussian', $blur);
    }
    $img->save($cacheSrc);
    $img->output();
} catch (Exception $e) {
    echo $e->getMessage();
}