Просмотр файла Soo_by_las/comm/resize.php

Размер файла: 3.23Kb
<?php
#-----------------------------------------------------#
#             ******   Сообщества    ******           #
#                    Site   :  http://cobwap.net      #
#                   E-mail  :  [email protected]          #
#                 Для связи :  8(909)651-0-222        #
#                      ICQ  :  384181109              #
#            Автор скрипта  :  LAS                    #
#-----------------------------------------------------#
require_once"../template/start.php";
require_once"../template/regglobals.php";
require_once"../template/config.php";
require_once"../template/functions.php";
$gdir = check($_GET['gdir']);
$gpoddir = check($_GET['gpoddir']);
$gname = check($_GET['gname']);
$them = check($_GET['them']);
$maxsize = check($_GET['maxsize']);
$image = check($_GET['image']);
$act = check($_GET['act']);

if($gdir!="" && $gpoddir!="" && $them!="" && $gname!=""){
if($maxsize==""){$maxsize = 100;}
$image=BASEDIR."$gdir/$gpoddir/$them/$gname";
if($act=="jpg"){
$size = GetImageSize($image); 
$width = $size[0]; 
$height = $size[1]; 

$x_ratio = $maxsize / $width; 
$y_ratio = $maxsize / $height; 

if ( ($width <= $maxsize) && ($height <= $maxsize) ) { 
  $tn_width = $width; 
  $tn_height = $height; 
} 
else if (($x_ratio * $height) < $maxsize) { 
  $tn_height = ceil($x_ratio * $height); 
  $tn_width = $maxsize; 
} 
else { 
  $tn_width = ceil($y_ratio * $width); 
  $tn_height = $maxsize; 
} 

$src = ImageCreateFromJpeg($image); 
$dst = ImageCreateTrueColor($tn_width,$tn_height); 
ImageCopyResized($dst, $src, 0, 0, 0, 0, 
    $tn_width,$tn_height,$width,$height); 
header("Content-type: image/jpeg"); 
ImageJpeg ($dst, null, 40);
ImageDestroy($src); 
ImageDestroy($dst); }	  
  	  
  	  
if($act=="gif"){
$size = GetImageSize($image); 
$width = $size[0]; 
$height = $size[1]; 

$x_ratio = $maxsize / $width; 
$y_ratio = $maxsize / $height; 

if ( ($width <= $maxsize) && ($height <= $maxsize) ) { 
  $tn_width = $width; 
  $tn_height = $height; 
} 
else if (($x_ratio * $height) < $maxsize) { 
  $tn_height = ceil($x_ratio * $height); 
  $tn_width = $maxsize; 
} 
else { 
  $tn_width = ceil($y_ratio * $width); 
  $tn_height = $maxsize; 
} 

$src = ImageCreateFromGif($image); 
$dst = ImageCreateTrueColor($tn_width,$tn_height); 
ImageCopyResized($dst, $src, 0, 0, 0, 0, 
    $tn_width,$tn_height,$width,$height); 
header("Content-type: image/gif"); 
ImageGif ($dst); 
ImageDestroy($src); 
ImageDestroy($dst); }	  	  
  	  
if($act=="png"){
$size = GetImageSize($image); 
$width = $size[0]; 
$height = $size[1]; 

$x_ratio = $maxsize / $width; 
$y_ratio = $maxsize / $height; 

if ( ($width <= $maxsize) && ($height <= $maxsize) ) { 
  $tn_width = $width; 
  $tn_height = $height; 
} 
else if (($x_ratio * $height) < $maxsize) { 
  $tn_height = ceil($x_ratio * $height); 
  $tn_width = $maxsize; 
} 
else { 
  $tn_width = ceil($y_ratio * $width); 
  $tn_height = $maxsize; 
} 

$src = ImageCreateFromPng($image); 
$dst = ImageCreateTrueColor($tn_width,$tn_height); 
ImageCopyResized($dst, $src, 0, 0, 0, 0, 
    $tn_width,$tn_height,$width,$height); 
header("Content-type: image/png"); 
ImagePng ($dst); 
ImageDestroy($src); 
ImageDestroy($dst); } 	  
}
?>