twister05
Guest
Вместо уменьшеной фотки получаю каракули,чегото нехватает?
Если делаю скрипт на 2-ой паге то фотка отображается в уменьшеном виде,а если на одной всё то сабж,в чём дело?
print"
<form enctype='multipart/form-data' action='index.php?picture=fotka' method='post'>
Загрузить фотку:<input type=\"file\" name=\"image\">
<input type=\"submit\" name=\"submit\" value=\"OK\" >";
switch($picture) :
case("fotka") :
$big_img = ImageCreateFromJPEG ("$image");
$small_img = ImageCreate(320,240);
$size = GetImageSize("$image");
$width = $size[0];
$height = $size[1];
$x_ratio = 320 / $width;
$y_ratio = 240 / $height;
if( ($width <= 320) && ($height <= 240) ) {
$tn_width = $width;
$tn_height = $height;
}
else if ( ($x_ratio * $height) < 240) {
$tn_height = ceil($x_ratio * $height) ;
$tn_width = 320;
}
else{
$tn_width = ceil($y_ratio * $width);
$tn_height = 240;
}
ImageCopyResized($small_img, $big_img, 0, 0, 0, 0, 320, 240, $size[0], $size[1]);
ImageJPEG($small_img);
ImageDestroy($big_img);
ImageDestroy($small_img);
endswitch;
Если делаю скрипт на 2-ой паге то фотка отображается в уменьшеном виде,а если на одной всё то сабж,в чём дело?
print"
<form enctype='multipart/form-data' action='index.php?picture=fotka' method='post'>
Загрузить фотку:<input type=\"file\" name=\"image\">
<input type=\"submit\" name=\"submit\" value=\"OK\" >";
switch($picture) :
case("fotka") :
$big_img = ImageCreateFromJPEG ("$image");
$small_img = ImageCreate(320,240);
$size = GetImageSize("$image");
$width = $size[0];
$height = $size[1];
$x_ratio = 320 / $width;
$y_ratio = 240 / $height;
if( ($width <= 320) && ($height <= 240) ) {
$tn_width = $width;
$tn_height = $height;
}
else if ( ($x_ratio * $height) < 240) {
$tn_height = ceil($x_ratio * $height) ;
$tn_width = 320;
}
else{
$tn_width = ceil($y_ratio * $width);
$tn_height = 240;
}
ImageCopyResized($small_img, $big_img, 0, 0, 0, 0, 320, 240, $size[0], $size[1]);
ImageJPEG($small_img);
ImageDestroy($big_img);
ImageDestroy($small_img);
endswitch;