<?php $Allowed_UploadFile_Ext=$Config->UploadImageExt; require('upload.do.php'); if ($UPLOADED_FILE) { $file_type=null; if (substr($UPLOADED_FILE,-4)=='.jpg') $file_type='jpg'; else if (substr($UPLOADED_FILE,-4)=='.gif') $file_type='gif'; else if (substr($UPLOADED_FILE,-4)=='.png') $file_type='png'; switch ($file_type) { case 'jpg': $imagesrc=imagecreatefromjpeg($UPLOADED_FILE); break; case 'gif': $imagesrc=imagecreatefromgif($UPLOADED_FILE); break; case 'png': $imagesrc=imagecreatefrompng($UPLOADED_FILE); break; } if ($imagesrc) { $src_sx=imagesx($imagesrc); $src_sy=imagesy($imagesrc); $dst_sx=$src_sx; $dst_sy=$src_sy; if ($dst_sx>$Config->Limits['thumbnail.sx']) { $dst_sy=$dst_sy*$Config->Limits['thumbnail.sx']/$dst_sx; $dst_sx=$Config->Limits['thumbnail.sx']; } if ($dst_sy>$Config->Limits['thumbnail.sy']) { $dst_sx=$dst_sx*$Config->Limits['thumbnail.sy']/$dst_sy; $dst_sy=$Config->Limits['thumbnail.sy']; } $dst_sx=floor($dst_sx); $dst_sy=floor($dst_sy); if ($dst_sx!=$src_sx) { $imagedst=imagecreatetruecolor($Config->Limits['thumbnail.sx'],$Config->Limits['thumbnail.sy']); $dst_x=$dst_sx<$Config->Limits['thumbnail.sx']?($Config->Limits['thumbnail.sx']-$dst_sx)>>1:0; $dst_y=$dst_sy<$Config->Limits['thumbnail.sy']?($Config->Limits['thumbnail.sy']-$dst_sy)>>1:0; imagefilledrectangle($imagedst,0,0,$Config->Limits['thumbnail.sx']-1,$Config->Limits['thumbnail.sy']-1,imagecolorallocate($imagedst,255,255,255)); imagecopyresampled($imagedst,$imagesrc,$dst_x,$dst_y,0,0,$dst_sx,$dst_sy,$src_sx,$src_sy); switch ($file_type) { case 'jpg': imagejpeg($imagedst,$UPLOADED_FILE,75); break; case 'gif': imagegif($imagedst,$UPLOADED_FILE); break; case 'png': imagepng($imagedst,$UPLOADED_FILE,9,PNG_ALL_FILTERS); break; } imagedestroy($imagedst); } imagedestroy($imagesrc); } } ?>