Resize Image

Jumat, 30 Oktober 2009

Merubah Ukuran Gambar

if ($typeimage=='GIF'){
        $im_src = imagecreatefromgif($imagepath.$imagename);
}elseif ($typeimage=='PNG'){
        $im_src = imagecreatefrompng($imagepath.$imagename);
}else{
        $im_src = imagecreatefromjpeg($imagepath.$imagename);
}

    $src_width = imageSX($im_src);
    $src_height = imageSY($im_src);

    //Simpan dalam versi medium 90 pixel
    $dst_width = 90;
    $dst_height = ($dst_width/$src_width)*$src_height;
    $im = imagecreatetruecolor($dst_width,$dst_height);
    imagecopyresampled($im, $im_src, 0, 0, 0, 0, $dst_width, $dst_height, $src_width, $src_height);
    imagejpeg($im,$imagepath."medium_".$imagename);
    
    imagedestroy($im_src);

    imagedestroy($im);
Bookmark and Share

Baca Juga



0 komentar:

Posting Komentar

 
 
 
 
Copyright © ramSon
Using RAM Theme