<?php
include("cfg.php");
if($sh=="") {$sh=40; $w1=$sh; }
if($w1=="") {$w1=$sh; }
$type=1;
$f=''.$a.'/'.$s.'';
if ($type == 1) $w = $sh;
if($qq=="") {$qq=100;}
if (!isset($q)) $q = $qq;
$src = imagecreatefromjpeg($f);
$w_src = imagesx($src);
$h_src = imagesy($src);
header("Content-type: image/jpeg");
if ($w_src != $w)
{if (($type==0)||($type==1))
{$dest = imagecreatetruecolor($w,$w1);
if ($w_src>$h_src)
imagecopyresized($dest, $src, 0, 0,
round((max($w_src,$h_src)-min($w_src,$h_src))/2),
0, $w, $w1, min($w_src,$h_src), min($w_src,$h_src));
if ($w_src<$h_src)
imagecopyresized($dest, $src, 0, 0, 0, 0, $w, $w1,
min($w_src,$h_src), min($w_src,$h_src));
if ($w_src==$h_src)
imagecopyresized($dest, $src, 0, 0, 0, 0, $w, $w1, $w_src, $w_src); }
imagejpeg($dest,'',$q);
imagedestroy($dest);
imagedestroy($src); }
imagecopyresized($dest, $src, 0, 0, 0, 0, $w,
$w1, min($w_src,$h_src), min($w_src,$h_src));
?>