php生成的图像在加载后消失


php generated image disapears after loading

我用这个代码来调整我的图像大小:

if ($height > $width) {
  $divisor = $width / $imgs;
} else {
  $divisor = $height / $imgs;
}
$resizedWidth   = ceil($width / $divisor);
$resizedHeight  = ceil($height / $divisor);

$xOffset = floor(($resizedWidth  - $imgs) / 2);
$yOffset = floor(($resizedHeight - $imgs) / 2);                                        
$resized  = imagecreatetruecolor($resizedWidth, $resizedHeight);
$thumb    = imagecreatetruecolor($imgs, $imgs);
imagecopyresized($resized, $im, 0, 0, 0, 0, $resizedWidth, $resizedHeight, $width, $height);
imagecopyresized($thumb, $resized, 0, 0, $xOffset, $yOffset, $imgs, $imgs, $imgs, $imgs);
imagepng($thumb, "test.png");           
$instr = fopen("test.png","rb");  
$imageThumb = addslashes(fread($instr,filesize("test.png")));    

风景效果很好,但当我上传肖像时,缩略图会被加载,直到它被完全看到,然后它就会消失。

header("Content-Disposition: attachment; filename=$title"); 
header("Content-length: $size"); 
header("Content-type: $type"); 
echo $image; 

这是一个美元大小的问题

确保使用正确的数据!

PS:为什么它在不同的方向上工作…这让我很困惑。