Exemplo n.º 1
0
 public static function create($pathOriginal, $width, $height, $option = self::NORMAL)
 {
     $original = new ThumbImage($pathOriginal);
     $thumbSize = array('width' => $width, 'height' => $height);
     $thumbPath = self::getPath($pathOriginal, $thumbSize, $option);
     $forceSize = $option != self::NORMAL and $option != self::HEIGHT;
     if (file_exists($thumbPath)) {
         return $thumbPath;
     }
     if ($original->correctSize($thumbSize)) {
         return $pathOriginal;
     }
     if ($original->isToSmall($thumbSize) && !$forceSize) {
         return $pathOriginal;
     }
     $image = $original->scale($thumbSize, $option);
     self::save($image, $thumbPath);
     return $thumbPath;
 }