<?php
#######################################################
# [Автор скрипта: ] #
# [Роман Гринько aka Nominal] #
# [ICQ: 405-623-516] [E-Mail: [email protected]] #
#######################################################
// Запрос вида ?t=gif&w=320&h=240&file=http://site/image.gif
$noprew = '../images/noprew.gif';
$nofile = '../images/nofile.gif';
Error_reporting(0);
$t = $_GET['t'];
$file = $_GET['file'];
if($_GET['w'] and $_GET['h']) { $w = $_GET['w']; $h = $_GET['h']; } else { $w = '100'; $h = '100'; }
##
if($file=='' or !isset($file)) {
$w = '100'; $h = '100';
function imageresize($outfile,$infile,$neww,$newh,$quality) {
header("Content-type: image/gif");
$im=imagecreatefromgif($infile);
$im1=imagecreatetruecolor($neww,$newh);
imagecopyresampled($im1,$im,0,0,0,0,$neww,$newh,imagesx($im),imagesy($im));
imagegif($im1,$outfile,$quality);
imagedestroy($im);
imagedestroy($im1);
}
imageresize("",$noprew,$w,$h,75);
exit();
}
##
if(!file_exists($file)) {
$w = '100'; $h = '100';
function imageresize($outfile,$infile,$neww,$newh,$quality) {
header("Content-type: image/gif");
$im=imagecreatefromgif($infile);
$im1=imagecreatetruecolor($neww,$newh);
imagecopyresampled($im1,$im,0,0,0,0,$neww,$newh,imagesx($im),imagesy($im));
imagegif($im1,$outfile,$quality);
imagedestroy($im);
imagedestroy($im1);
}
imageresize("",$nofile,$w,$h,75);
exit();}
##
switch($t) {
case 'jpg':
function imageresize($outfile,$infile,$neww,$newh,$quality) {
header("Content-type: image/jpeg");
$im=imagecreatefromjpeg($infile);
$im1=imagecreatetruecolor($neww,$newh);
imagecopyresampled($im1,$im,0,0,0,0,$neww,$newh,imagesx($im),imagesy($im));
imagejpeg($im1,$outfile,$quality);
imagedestroy($im);
imagedestroy($im1);
}
break;
case 'gif':
function imageresize($outfile,$infile,$neww,$newh,$quality) {
header("Content-type: image/gif");
$im=imagecreatefromgif($infile);
$im1=imagecreatetruecolor($neww,$newh);
imagecopyresampled($im1,$im,0,0,0,0,$neww,$newh,imagesx($im),imagesy($im));
imagegif($im1,$outfile,$quality);
imagedestroy($im);
imagedestroy($im1);
}
break;
default:
$w = '100'; $h = '100';
function imageresize($outfile,$infile,$neww,$newh,$quality) {
header("Content-type: image/gif");
$im=imagecreatefromgif($infile);
$im1=imagecreatetruecolor($neww,$newh);
imagecopyresampled($im1,$im,0,0,0,0,$neww,$newh,imagesx($im),imagesy($im));
imagegif($im1,$outfile,$quality);
imagedestroy($im);
imagedestroy($im1);
}
imageresize("",$noprew,$w,$h,75);
exit();
}
imageresize("",$file,$w,$h,75);
?>