Esempio n. 1
0
if (!isset($_GET) || empty($_GET)) {
    throw new Exception("Paramètres d'image manquants");
}
// Bootstrap
$Bootstrap = Bootstrap::getInstance();
$Bootstrap->setEnv(ENV);
$Bootstrap->loadConfigs(ROOT . '/configs/');
$default = array('src' => false, 'width' => false, 'height' => false, 'mode' => false);
extract(array_merge($default, $_GET));
if (!$height) {
    $height = $width;
}
if (Config::get('cache.pictures')) {
    sort($_GET);
    $cachename = ROOT . 'cache/' . sha1($src . '&' . http_build_query($_GET));
    $Cache = new CacheComponent($cachename, '-1 month');
    $Cache->open();
}
$Image = new ImageComponent(ROOT . 'www' . $src);
if ($mode == 'crop') {
    $Image->thumbnail($width, $height);
} elseif ($mode == 'zoom') {
    $Image->zoom($width, $height);
} elseif ($width || $height) {
    $Image->resize($width, $height);
}
$Image->show();
if (Config::get('cache.pictures')) {
    $Cache->close();
}
flush();