View file demon_load/downloads/prew.php

File size: 2.58Kb
<?














$scr_file = imagecreatefromjpeg("downloads/jpg/$jpg[$jp]/$files[$k]");
$old_img = getimagesize("downloads/jpg/$jpg[$jp]/$files[$k]");
$ratio = $old_img[0]/$old_img[1];
if ($old_img[0]==$old_img[1]){
$new_img[0]=$w;
$new_img[1]=$h;}
else {
if ($old_img[0]>$old_img[1])
{
$ratio=$old_img[1]/$old_img[0];
$new_img[0]=$w;
$new_img[1]=$h*$ratio;

}
else
{
$ratio=$old_img[0]/$old_img[1];
$new_img[0]=$w*$ratio;
$new_img[1]=$h;}}
$new_pic = imagecreatetruecolor($new_img[0], $new_img[1]);
imagefill($new_pic, 0, 0, 0xF7F1FF);
imagecopyresampled($new_pic, $scr_file, 0, 0, 0, 0, $new_img[0], $new_img[1], $old_img[0], $old_img[1]);
imagejpeg($new_pic, "downloads/jpg/$jpg[$jp]/tmp/$files[$k]");




















$l1=$_GET['l_wid'];
$l2=$_GET['l_hei'];
$resize="$l2$l1";




$dir_orig = opendir ("downloads/jpg/$jpg[$jp]");
$k_or="0";
while ($file_or = readdir ($dir_orig)) 
{
if (
$file_or=="index.php"||
$file_or=="tmp"||
$file_or=="128128"||
$file_or=="128160"||
$file_or=="132176"||
$file_or=="index.gif"
)
{}
else {
$kart_orig["$k_or"]=$file_or;
$k_or=$k_or+1;}
}
closedir ($dir_orig);


$dir_new = opendir ("downloads/jpg/$jpg[$jp]/$resize");
$k_n="0";
while ($file_n = readdir ($dir_new)) 
{
if (
$file_n=="index.php"||
$file_n=="tmp"||
$file_n=="128128"||
$file_n=="128160"||
$file_n=="132176"||
$file_n=="index.gif"
)
{}
else {
$kart_new["$k_n"]=$file_n;
$k_n=$k_n+1;}
}
closedir ($dir_new);




$scr_file2 = imagecreatefromjpeg("downloads/jpg/$jpg[$jp]/$files[$k]");
$old_img2 = getimagesize("downloads/jpg/$jpg[$jp]/$files[$k]");
$ratio2 = $old_img2[0]/$old_img2[1];
if ($l1==$l2){
if ($old_img2[0]>$old_img2[1])
{
$new_img2[0]=$l2*$ratio2;
$new_img2[1]=$l2;
$sdvig_w=0;
$sdvig_h=-($new_img2[0]-$l2)/2;
}
else
{
$new_img2[1]=$l2/$ratio2;
$new_img2[0]=$l2;
$sdvig_w=-($new_img2[1]-$l2)/2;
$sdvig_h=0;


}


}
else {
if ($l2>$l1)
{


$new_img2[0]=$l2;
$new_img2[1]=$l2*$ratio2;
$sdvig_w=-($new_img2[1]-$l1)/2;
$sdvig_h=0;
}
else
{

$new_img2[1]=$l1;
$new_img2[0]=$l1*$ratio2;
$sdvig_h=-($new_img2[0]-$l2)/2;
$sdvig_w=0;
}}
$new_pict2 = imagecreatetruecolor($l2,$l1);
imagecopyresampled($new_pict2, $scr_file2, $sdvig_h, $sdvig_w, 0, 0, $new_img2[0], $new_img2[1], $old_img2[0], $old_img2[1]);
imagejpeg($new_pict2, "downloads/jpg/$jpg[$jp]/$resize/$files[$k]");




echo " <img src=\"downloads/jpg/$jpg[$jp]/tmp/$files[$k]\" height=\"$new_img[1]\" width=\"$new_img[0]\"\">";
echo "<a href=\"downloads/jpg/$jpg[$jp]/$resize/$files[$k]\"> $files[$k]</a><br>";
?>