
if($sFileExtension == "PNG" || $sFileExtension == "png")
{
$img1 = @imagecreatefrompng($file);
}
else
{
$img1 = imagecreatefromjpeg($file);
}
$width1 = @imagesx($img1);
$height1 = @imagesy($img1);
if ($width1 > $height1)
{
$y1 = 0;
$x1 = ($width1 - $height1) / 2;
$smallestSide1 = $height1;
}
else
{
$x1 = 0;
$y1 = ($height1 - $width1) / 2;
$smallestSide1 = $width1;
}
$thumbSize1 = 160;
$thumb1 = imagecreatetruecolor($thumbSize1, $thumbSize1);
imagecolortransparent($thumb1, imagecolorallocatealpha($thumb1, 255, 255, 255, 127));
imagealphablending($thumb1, false);
imagesavealpha($thumb1, true);
@imagecopyresampled($thumb1, $img1, 0, 0, $x1, $y1, $thumbSize1, $thumbSize1, $smallestSide1, $smallestSide1);
if($sFileExtension == "PNG" || $sFileExtension == "png")
{
imagepng( $thumb1, $file);//third parameter is $quality its option
}
else
{
imagejpeg( $thumb1, $file);//third parameter is $quality its option
}