function thumbs($outpath,$inpath,$outimg,$inimg,$insize) {
if(@copy("".$outpath."/".$outimg."", "".$inpath."/".$inimg."")) {
$f_name = end(explode(".", $inimg));
$f_extension = strtolower($f_name);
if ($f_extension == "jpg" && extension_loaded("gd")) {
$src_img= ImageCreateFromJpeg("".$inpath."/".$inimg."");
$src_width= ImagesX($src_img);
$src_height= ImagesY($src_img);
$dest_width = $insize;
$dest_height = $src_height/($src_width/$dest_width);
$dest_img=ImageCreateTrueColor($dest_width, $dest_height);
ImageCopyResampled($dest_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $src_width, $src_height);
ImageJpeg($dest_img, "".$inpath."/".$inimg."", 100);
ImageDestroy($dest_img);
}
if ($f_extension == "png" && extension_loaded("gd")) {
$src_img= imagecreatefrompng("".$inpath."/".$inimg."");
$src_width= imagesx($src_img);
$src_height= imagesy($src_img);
$dest_width = $insize;
$dest_height = $src_height/($src_width/$dest_width);
$dest_img=imagecreatetruecolor($dest_width, $dest_height);
imagecopyresampled($dest_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $src_width, $src_height);
imagepng($dest_img, "".$inpath."/".$inimg."");
imagedestroy($dest_img);
}
if ($f_extension == "gif" && extension_loaded("gd")) {
$src_img= imagecreatefromgif("".$inpath."/".$inimg."");
$src_width= imagesx($src_img);
$src_height= imagesy($src_img);
$dest_width = $insize;
$dest_height = $src_height/($src_width/$dest_width);
$dest_img=imagecreatetruecolor($dest_width, $dest_height);
imagecopyresampled($dest_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $src_width, $src_height);
imagegif($dest_img, "".$inpath."/".$inimg."", 100);
imagedestroy($dest_img);
}
}
}
Không có nhận xét nào:
Đăng nhận xét