View file catalogdeep/test/screen.php

File size: 888B
<?

if (!isset($_GET['img']))
{
exit;
}

$max_width = $_GET['w']; 
$max_height = $_GET['h']; 

$image=base64_decode($_GET['img']);
$size = GetImageSize($image); 
$width = $size[0]; 
$height = $size[1]; 

$x_ratio = $max_width / $width; 
$y_ratio = $max_height / $height; 

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

$src = ImageCreateFromPng($image); 

$dst = ImageCreateTrueColor($tn_width,$tn_height); 

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