Ejemplo n.º 1
0
 public function imageThumbCreate(&$cur, $f)
 {
     $file = $this->pwd . '/' . $f;
     if (!file_exists($file)) {
         return false;
     }
     $p = path::info($file);
     $thumb = sprintf($this->thumb_tp, $p['dirname'], $p['base'], '%s');
     try {
         $img = new imageTools();
         $img->loadImage($file);
         $w = $img->getW();
         $h = $img->getH();
         $this->imageThumbRemove($f);
         foreach ($this->thumb_sizes as $suffix => $s) {
             if ($s[0] > 0 && ($suffix == 'sq' || $w > $s[0] || $h > $s[0])) {
                 $img->resize($s[0], $s[0], $s[1]);
                 $img->output('jpeg', sprintf($thumb, $suffix), 80);
             }
         }
         $img->close();
     } catch (Exception $e) {
         if ($cur === null) {
             # Called only if cursor is null (public call)
             throw $e;
         }
     }
 }
Ejemplo n.º 2
0
 public function imageThumbCreate($cur, $f, $force = true)
 {
     $file = $this->pwd . '/' . $f;
     if (!file_exists($file)) {
         return false;
     }
     $p = path::info($file);
     $alpha = $p['extension'] == 'png' || $p['extension'] == 'PNG';
     $thumb = sprintf($alpha ? $this->thumb_tp_alpha : $this->thumb_tp, $p['dirname'], $p['base'], '%s');
     try {
         $img = new imageTools();
         $img->loadImage($file);
         $w = $img->getW();
         $h = $img->getH();
         if ($force) {
             $this->imageThumbRemove($f);
         }
         foreach ($this->thumb_sizes as $suffix => $s) {
             $thumb_file = sprintf($thumb, $suffix);
             if (!file_exists($thumb_file) && $s[0] > 0 && ($suffix == 'sq' || $w > $s[0] || $h > $s[0])) {
                 $rate = $s[0] < 100 ? 95 : ($s[0] < 600 ? 90 : 85);
                 $img->resize($s[0], $s[0], $s[1]);
                 $img->output($alpha ? 'png' : 'jpeg', $thumb_file, $rate);
                 $img->loadImage($file);
             }
         }
         $img->close();
     } catch (Exception $e) {
         if ($cur === null) {
             # Called only if cursor is null (public call)
             throw $e;
         }
     }
 }