Пример #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
/**
 * Save image in various colors for the homepage and the nav bars
 * 
 * @param
 * @return
 */
function saveWebCoverImage($image)
{
    //1.Original Image
    // Separate the uploaded file array
    list($name, $type, $tmp, $err, $size) = array_values($image);
    //get extension
    $ext = getImageExtensions($type);
    //rename
    $filename = "cover_original" . $ext;
    $coverimagePath = $_SERVER['DOCUMENT_ROOT'] . APP_FOLDER . "/img/original/" . $filename;
    //save original
    if (!move_uploaded_file($tmp, $coverimagePath)) {
        throw new Exception("Couldn't save the uploaded image!");
    }
    //2.save small and medium image
    $destination = '../img/' . "cover_red" . $ext;
    $img = new abeautifulsite\SimpleImage($coverimagePath);
    $img->desaturate()->contrast(30)->brightness(-40)->colorize('#bf1e2e', 0.8)->save('../img/' . "cover_red" . $ext);
    $img->desaturate()->contrast(10)->brightness(-80)->colorize('#648c8c', 0.8)->save('../img/' . "cover_green" . $ext);
    $img->desaturate()->contrast(0)->brightness(-100)->colorize('#a1a274', 0.8)->save('../img/' . "cover_beige" . $ext);
}