<?php $allowed_types = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png'); //include('header'); include('include/upload.class'); include('include/count.class'); include('include/form.class'); $extensions = null; if ($_FILES["myfile1"]["type"] == 'image/gif') $extensions = array('.gif', '.jpg', '.png'); else if ($_FILES["myfile1"]["type"] == 'image/jpeg' || $_FILES["myfile1"]["type"] == 'image/pjpeg') $extensions = array('.jpg', '.gif', '.png'); else $extensions = array('.png', '.gif', '.jpg'); if($extensions[0] == '.gif') $img_src = imagecreatefromgif($_FILES["myfile1"]["tmp_name"]); elseif($extensions[0] == '.jpg') $img_src = imagecreatefromjpeg($_FILES["myfile1"]["tmp_name"]); else $img_src = imagecreatefrompng($_FILES["myfile1"]["tmp_name"]); // Now check the width/height list($width, $height, ,) = getimagesize($_FILES["myfile1"]["tmp_name"]); //resize and create the full picture if ($width>$w OR $height>$h) { // If width is bigger than height if ($height<=$width) $ratio = $w/$width; else $ratio = $h/$height; } else { $ratio = 1; // No resize } $img_dest = imagecreatetruecolor(round($width*$ratio), round($height*$ratio)); imagecopyresized($img_dest,$img_src,0,0,0,0,round($width*$ratio),round($height*$ratio),$width,$height); imagejpeg($img_dest, 'images/'.$count.'.jpeg', 100); include('header'); echo 'Размер изображения до сжатия: '.round(filesize($_FILES["myfile1"]["tmp_name"])/1024).' Кб. ('.round(filesize($_FILES["myfile1"]["tmp_name"])/1048576, 3).' Мб.)<br>'."\n"; echo 'Размер изображения после сжатия: '.round(filesize('images/'.$count.'.jpeg')/1024).' Кб. ('.round(filesize('images/'.$count.'.jpeg')/1048576, 3).' Мб.)<br>'."\n"; echo 'Разрешение: '.round($width*$ratio).'x'.round($height*$ratio).' пикселей<br>'."\n"; echo 'Ссылка на файл: <a href="http://image-resize.ru/?'.$count.'">http://image-resize.ru/?'.$count.'</a>'; include('footer'); //include('footer'); ?> |