Добрый день.
Проблема следующая.
Есть код:
function imageResize($image, $newWidth, $newHeight) {
$image=urldecode($image);
$size = GetImageSize($image);
$width = $size[0];
$height = $size[1];
if($width>$height){
$need_ratio = $width/$newWidth;
$n_width = $newWidth;
$n_height = $height/$need_ratio;
$ofset_y = ($newHeight - $n_height)/2;
if($n_height>$newHeight){
$need_ratio = $height/$newHeight;
$n_width = $width/$need_ratio;
$n_height = $newHeight;
$ofset_x = ($newWidth - $n_width)/2;
$ofset_y = ($newHeight - $n_height)/2;
}
}
else {
$need_ratio = $height/$newHeight;
$n_width = $width/$need_ratio;
$n_height = $newHeight;
$ofset_x = ($newWidth - $n_width)/2;
if($n_width>$newWidth){
$need_ratio = $width/$newWidth;
$n_width = $newWidth;
$n_height = $height/$need_ratio;
$ofset_y = ($newHeight - $n_height)/2;
$ofset_x = ($newWidth - $n_width)/2;
}
}
if($size[2]==IMAGETYPE_GIF){
$src = ImageCreateFromGif($image);
}
else if($size[2]==IMAGETYPE_JPEG){
$src = ImageCreateFromJpeg($image);
}
else {
$src = ImageCreateFromPNG($image);
}
$dst = ImageCreateTrueColor($newWidth,$newHeight);
$background_color = imagecolorallocate($dst, 255, 255, 255);
imagefilledrectangle($dst, 0,0, $newWidth, $newHeight, $background_color);
ImageCopyResampled($dst, $src, $ofset_x, $ofset_y, 0, 0,
$n_width,$n_height,$width,$height);
if($size[2]==IMAGETYPE_GIF){
header("Content-type: image/gif");
ImageGif($dst);
}
else if($size[2]==IMAGETYPE_JPEG){
header("Content-type: image/jpeg");
ImageJpeg($dst, null, 100);
}
else {
header("Content-type: image/png");
ImagePNG($dst);
}
ImageDestroy($src);
ImageDestroy($dst);
}
Превью не выводится. Причем если убираю header -получаю положенную абракадабру.
Тот же самый код на другом сайте успешно работает. Где искать косяк?