コード例 #1
0
ファイル: index.php プロジェクト: skaligotla/kplaylist
 function rewrite($fpath)
 {
     global $cfg;
     if (file_exists($fpath)) {
         $fdesc = new filedesc($fpath);
         if ($fdesc->found) {
             $nh = $nw = 0;
             imgcoords($this->w, $this->h, $fpath, $nw, $nh, false);
             if ($imagesize = getimagesize($fpath)) {
                 $w = $imagesize[0];
                 $h = $imagesize[1];
                 $image = false;
                 $image_p = imagecreatetruecolor($nw, $nh);
                 if (is_resource($image_p)) {
                     switch ($fdesc->extension) {
                         case 'gif':
                             if (function_exists('imagecreatefromgif') && function_exists('imagegif')) {
                                 $image = imagecreatefromgif($fpath);
                             }
                             break;
                         case 'png':
                             if (function_exists('imagecreatefrompng') && function_exists('imagepng')) {
                                 $image = imagecreatefrompng($fpath);
                             }
                             break;
                         case 'jpeg':
                         case 'jpg':
                             if (function_exists('imagecreatefromjpeg') && function_exists('imagejpeg')) {
                                 $image = imagecreatefromjpeg($fpath);
                             }
                             break;
                     }
                 }
                 if ($image) {
                     imagecopyresampled($image_p, $image, 0, 0, 0, 0, $nw, $nh, $w, $h);
                     if (imagejpeg($image_p, $this->getfname(), $cfg['jpeg-quality'])) {
                         return true;
                     }
                 }
             }
         }
     }
 }
コード例 #2
0
ファイル: index.php プロジェクト: Git-Host/AMPPS
 function resize()
 {
     $src = '';
     if ($this->dirimageid != -1) {
         $f2 = new file2($this->dirimageid, false);
         $src = $f2->fullpath;
     } else {
         if ($this->id3v2imageid != -1) {
             $f2 = new file2($this->id3v2imageid, false);
             $src = $f2->mklink('imgid3sid', 'album.jpg');
         }
     }
     if (!empty($src)) {
         $nw = $nh = 0;
         imgcoords($this->width, $this->height, $src, $nw, $nh);
         $this->width = $nw;
         $this->height = $nh;
         $this->scale = true;
     }
 }