Ejemplo n.º 1
0
 public static function small($file)
 {
     require_once dirname(__FILE__) . '/../phpthumb/phpthumb.class.php';
     $basefile = new File($file);
     $basepath = File::a2r($file);
     $webimg = dirname($basepath) . "/" . $basefile->name . "_small." . $basefile->extension;
     list($x, $y) = getimagesize($file);
     if ($x <= 1200 && $y <= 1200) {
         return $file;
     }
     $path = File::r2a($webimg, Settings::$thumbs_dir);
     /// Create smaller image
     if (!file_exists($path) || filectime($file) > filectime($path)) {
         if (!file_exists(dirname($path))) {
             @mkdir(dirname($path), 0755, true);
         }
         $thumb = new phpthumb();
         $thumb->config_imagemagick_path = Settings::$imagemagick_path;
         $thumb->setSourceData(file_get_contents($file));
         $thumb->CalculateThumbnailDimensions();
         $thumb->w = 1200;
         $thumb->h = 1200;
         $thumb->q = Settings::$quality_small;
         if (File::Type($file) == 'Image' && Provider::get_orientation_degrees($file) != 0) {
             $thumb->SourceImageToGD();
             //$thumb->ra = Provider::get_orientation_degrees($file);
             $thumb->Rotate();
         }
         $thumb->GenerateThumbnail();
         $thumb->RenderToFile($path);
     }
     return $path;
 }