0

このコードを使用して画像のサイズを変更しました。

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")));    

横向きは問題なく機能しますが、縦向きをアップロードすると、サムネイルが完全に表示されるまで読み込まれ、その後消えます。

4

1 に答える 1

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

それは $size の問題でした。-.-

正しいデータを使用してください。

PS: 異なる向きで機能するのはなぜですか? …それは私を混乱させました。

于 2013-02-26T02:42:45.123 に答える