PHP: เปลี่ยนขนาดรูปภาพ JPEG

<?php
	function imageResize( $ori_file, $new_file )
	{
		$max_imageSize = 100;
		$ori_size = getimagesize($ori_file);
		$ori_w = $ori_size[0];
		$ori_h = $ori_size[1];

		if($ori_w > $ori_h) {
			$new_w = $max_imageSize;
			$new_h = round(($new_w/$ori_w) * $ori_h);
		}
		else
		{
			$new_h = $max_imageSize;
			$new_w = round(($new_h/$ori_h) * $ori_w);
		}

		$ori_img = imagecreatefromjpeg($ori_file);
		$new_img = imagecreatetruecolor($new_w, $new_h);
		imagecopyresized($new_img, $ori_img, 0, 0, 0, 0, $new_w, $new_h, $ori_w, $ori_h);

		imagejpeg($new_img, $new_file);
		imagedestroy($ori_img);
		imagedestroy($new_img);
	}

	$imagePath = "./images/";
	$ori_file = $imagePath . "test.jpg";
	$new_file = $imagePath . "test_resize.jpg";

	echo "<H1>Start resizing image</h1>";
	imageResize( $ori_file, $new_file );

	echo "<H1>Resize complete</h1>";
	echo "<img src='$ori_file'>";
	echo "<img src='$new_file'>";
?>