このコードを使用して画像のサイズを変更しました。
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")));
横向きは問題なく機能しますが、縦向きをアップロードすると、サムネイルが完全に表示されるまで読み込まれ、その後消えます。