第一个选项有效,第二个选项没有......我不明白为什么?我拍摄1500×1500像素的图像,如果它通过第一个选项,结果是正确的,如果它通过第二个,我在右边和底部得到一个黑色边框......
if ($this_imagesize[0] > 1000)
{
$thumb_source = imagecreatefromjpeg('/path/' . $this_image_id . '.jpg');
$thumbnail = imagecreatetruecolor(1000, intval(1000 * ($this_imagesize[1] / $this_imagesize[0])));
imagefill($thumbnail, 0, 0, imagecolorallocate($tn, 255, 255, 255));
imagecopyresampled($thumbnail, $thumb_source, 0, 0, 0, 0, 1000, intval(1000 * ($this_imagesize[1] / $this_imagesize[0])), $this_imagesize[0], $this_imagesize[1]);
unlink('/path/' . $this_image_id . '.jpg');
imagejpeg($thumbnail, '/path/' . $this_image_id . '.jpg', 75);
}
if ($this_imagesize[1] > 1000)
{
$thumb_source = imagecreatefromjpeg('/path/' . $this_image_id . '.jpg');
$thumbnail = imagecreatetruecolor(intval(1000 * ($this_imagesize[0] / $this_imagesize[1])), 1000);
imagecopyresampled($thumbnail, $thumb_source, 0, 0, 0, 0, intval(1000 * ($this_imagesize[0] / $this_imagesize[1])), 1000, $this_imagesize[0], $this_imagesize[1]);
unlink('/path/' . $this_image_id . '.jpg');
imagejpeg($thumbnail, '/path/' . $this_image_id . '.jpg', 75);
}