Example #1
0
 public function checkExtOutputFormat($params)
 {
     if (!is_string($params['path'])) {
         throw new PhpResizer_Exception_Basic(sprintf(self::EXC_BAD_PARAM, 'path'));
     }
     $ext = PhpResizer_PhpResizer::getExtension($params['path']);
     if (!in_array($ext, $this->types)) {
         throw new PhpResizer_Exception_IncorrectExtension(sprintf(self::EXC_EXTENSION_IS_NOT_AVALIBLE, $ext, implode(',', $this->types)));
     }
     if (!$params['cacheFile'] || !is_string($params['cacheFile'])) {
         throw new PhpResizer_Exception_Basic(sprintf(self::EXC_BAD_PARAM, 'cacheFile'));
     }
 }
Example #2
0
        $k = 0.3;
        $round = 10;
        if (isset($_GET['h'])) {
            $opt['height'] = floor((int) $_GET['h'] * $k / $round) * $round;
        } else {
            $opt['height'] = 200;
        }
    } elseif ($_GET['type'] == 'startpage' && isset($_GET['w']) && isset($_GET['h'])) {
        $k = 0.4;
        $w = (int) $_GET['w'];
        $h = (int) $_GET['h'];
        $round = 10;
        $opt['height'] = floor($h * $k / $round) * $round;
        $opt['width'] = $opt['height'] * 2;
    }
    $rootPath = dirname(dirname(dirname(__FILE__))) . '/';
} else {
    $opt = array();
    $rootPath = dirname(__FILE__) . '/';
}
$path = realpath(dirname(__FILE__) . '/../../system/Library/');
require $path . '/PhpResizer/Autoloader.php';
new PhpResizer_Autoloader();
try {
    $resizer = new PhpResizer_PhpResizer(array('cacheDir' => realpath(dirname(__FILE__) . '/../../tmp/PhpResizer/'), 'tmpDir' => realpath(dirname(__FILE__) . '/../../tmp/tmp/'), 'cache' => true, 'cacheBrowser' => true, 'engine' => PhpResizer_PhpResizer::ENGINE_GD2));
    $resizer->resize($rootPath . $file, $opt);
} catch (Exception $e) {
    echo $e->getMessage();
    echo $e->getFile();
    echo $e->getLine();
}