...
<?php
$img = 'example.jpg' ;
$info = getimagesize( $img );
$w_or = $info [ 0 ];
$h_or = $info [ 1 ];
$type = $info [ 'mime' ];
$im1 = '' ;
if ( $type == 'image/jpeg' )
$im1 = ImageCreateFromJpeg ( $img );
if ( $type == 'image/gif' )
$im1 = ImageCreateFromGif ( $img );
if ( $type == 'image/png' )
$im1 = ImageCreateFromPng ( $img );
if (! $im1 )
die ( 'ошибка' );
if ( $w_or > $h_or )
{
$k = $w_or / 80 ;
}
else
{
$k = $h_or / 80 ;
}
$w = round ( $w_or / $k );
$h = round ( $h_or / $k );
$im2 = imagecreatetruecolor ( $w , $h );
imagecopyresampled( $im2 , $im1 , 0 , 0 , 0 , 0 , $w , $h , $w_or , $h_or );
if ( $type == 'image/jpeg' )
{
header( 'Content-type:image/jpeg' );
ImageJpeg ( $im2 );
}
elseif ( $type == 'image/gif' )
{
header( 'Content-type:image/gif' );
ImageGif ( $im2 );
}
elseif ( $type == 'image/png' )
{
header( 'Content-type:image/png' );
ImagePng ( $im2 );
}
else die( 'ошибка' );
?>