Exemple #1
0
 public static function resize($image, $destination, $width, $height, $filter = NULL)
 {
     ImageValidate::mustBeImage($image);
     StringValidate::mustBeNotEmpty($destination, "Destination must not be empty");
     $width = (int) $width;
     $height = (int) $height;
     IntValidate::mustBePositive($width, "Image width must be a positive number");
     IntValidate::mustBePositive($height, "Image height must be a positive number");
     $filter = empty($filter) ? \Imagick::FILTER_LANCZOS : $filter;
     $destDir = dirname($destination);
     if (!is_dir($destDir)) {
         if (!@mkdir($destDir, $mode = 0777, $recursive = TRUE)) {
             throw new \Exception("Could not create directory {$destDir} to save resized image");
         }
     }
     $resize = new \Imagick();
     $resize->readImage($image);
     $resize->resizeImage($width, $height, $filter, 1, $bestFit = TRUE);
     $resize->writeImage($destination);
     $resize->clear();
     $resize->destroy();
 }
Exemple #2
0
 public function limit($limit)
 {
     \apf\validate\Int::mustBePositive($limit, "Limit must be a positive number");
     $this->sqlArray["limit"] = (int) $limit;
     return $this;
 }
Exemple #3
0
 public function getPath($number)
 {
     if (empty($this->request)) {
         return NULL;
     }
     IntValidate::mustBeGreaterThan($number, 0, 'Path number must be a number greater than 0');
     return StringUtil::tokenize($this->request, '/', $number);
 }
Exemple #4
0
 public function iterateFragment($frag, $folder, $times = 0, $data = NULL)
 {
     Int::mustBePositive($times, "Amount of iterations must be a number greater than 0");
     for ($i = 0; $i < $times; $i++) {
         $this->loadFragment($frag, $folder, $data);
     }
 }