Exemplo n.º 1
0
function resizeImage($src_imagename, $maxwidth, $maxheight, $savename, $file_type)
{
    $im = createimg($src_imagename, $file_type);
    if ($im) {
        $current_width = imagesx($im);
        $current_height = imagesy($im);
        $resizewidth_tag = false;
        $resizeheight_tag = false;
        $widthratio = 1;
        $heightratio = 1;
        $ratio = 1;
        if ($maxwidth && $current_width > $maxwidth || $maxheight && $current_height > $maxheight) {
            if ($maxwidth && $current_width > $maxwidth) {
                $widthratio = $maxwidth / $current_width;
                $resizewidth_tag = true;
            }
            if ($maxheight && $current_height > $maxheight) {
                $heightratio = $maxheight / $current_height;
                $resizeheight_tag = true;
            }
            if ($resizewidth_tag && $resizeheight_tag) {
                if ($widthratio < $heightratio) {
                    $ratio = $widthratio;
                } else {
                    $ratio = $heightratio;
                }
            }
            if ($resizewidth_tag && !$resizeheight_tag) {
                $ratio = $widthratio;
            }
            if ($resizeheight_tag && !$resizewidth_tag) {
                $ratio = $heightratio;
            }
            $newwidth = $current_width * $ratio;
            $newheight = $current_height * $ratio;
            if (function_exists("imagecopyresampled")) {
                $newim = imagecreatetruecolor($newwidth, $newheight);
                imagecopyresampled($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $current_width, $current_height);
            } else {
                $newim = imagecreate($newwidth, $newheight);
                imagecopyresized($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $current_width, $current_height);
            }
            showimg($newim, $savename, $file_type);
            imagedestroy($newim);
        } else {
            imagejpeg($im, $savename);
        }
    }
}
Exemplo n.º 2
0
 function getimage()
 {
     $ok = false;
     if ($this->check()) {
         $fname = $this->getfname();
         if (!file_exists($fname)) {
             $this->createsid();
         }
         if (file_exists($fname)) {
             $this->send($fname);
             return true;
         }
     }
     if ($this->id3v2) {
         id3v2image($this->sid, true, true);
     } else {
         createimg($this->sid, true, $this->w, $this->h);
     }
 }
Exemplo n.º 3
0
 function senddata()
 {
     if ($this->dirimageid != -1) {
         if ($this->scale) {
             createimg($this->dirimageid, false);
         } else {
             $f2 = new file2($this->dirimageid);
             if ($f2->ifexists()) {
                 readfile($f2->fullpath);
             }
         }
     } else {
         if ($this->id3v2imageid != -1) {
             id3v2image($this->id3v2imageid, true, false);
         }
     }
 }