The first option works, the second doesn’t … I don’t get why? I take an image 1500 by 1500 pixels, if it gets passed through the first option the result is right, if it gets passed through the second, I get a black border on the right and on the bottom …
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);
}