예제 #1
0
    $command[] = '"' . $thumb->destination->root . '"';
    exec(implode(' ', $command));
};
/**
 * GDLib Driver
 */
thumb::$drivers['gd'] = function ($thumb) {
    try {
        $img = new abeautifulsite\SimpleImage($thumb->root());
        $img->quality = $thumb->options['quality'];
        if ($thumb->options['crop']) {
            @$img->thumbnail($thumb->options['width'], $thumb->options['height']);
        } else {
            $dimensions = clone $thumb->source->dimensions();
            $dimensions->fitWidthAndHeight($thumb->options['width'], $thumb->options['height'], $thumb->options['upscale']);
            @$img->resize($dimensions->width(), $dimensions->height());
        }
        if ($thumb->options['grayscale']) {
            $img->desaturate();
        }
        if ($thumb->options['blur']) {
            $img->blur('gaussian', $thumb->options['blurpx']);
        }
        if ($thumb->options['autoOrient']) {
            $img->auto_orient();
        }
        @$img->save($thumb->destination->root);
    } catch (Exception $e) {
        $thumb->error = $e;
    }
};
예제 #2
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();
}
예제 #3
0
    if ($thumb->options['blur']) {
        $command[] = '-blur 0x8';
    }
    $command[] = '"' . $thumb->destination->root . '"';
    exec(implode(' ', $command));
};
/**
 * GDLib Driver
 */
thumb::$drivers['gd'] = function ($thumb) {
    try {
        $img = new abeautifulsite\SimpleImage($thumb->root());
        $img->quality = $thumb->options['quality'];
        if ($thumb->options['crop']) {
            @$img->thumbnail($thumb->options['width'], $thumb->options['height']);
        } else {
            $dimensions = clone $thumb->source->dimensions();
            $dimensions->fitWidthAndHeight($thumb->options['width'], $thumb->options['height'], $thumb->options['upscale']);
            @$img->resize($dimensions->width(), $dimensions->height());
        }
        if ($thumb->options['grayscale']) {
            $img->desaturate();
        }
        if ($thumb->options['blur']) {
            $img->blur('gaussian', 10);
        }
        @$img->save($thumb->destination->root);
    } catch (Exception $e) {
        $thumb->error = $e;
    }
};