/** resize_image() * * This functions resizes an image to any size * specified. * * @ARGUMENTS: 2 * - $image: This is the path to the image to be resized * - $target: This is the target widht/height * @RETURNS: * - html width/height string for an image tag **/ function resize_image($image,$target) { // Get the current image size $image = getimagesize($image); // Get the percentage to resize the image if ($image[0] > $image[1]) { $percent = $target / $image[0]; } else { $percent = $target / $image[1]; } // Get the new width and height $w = round($image[0] * $percent); $h = round($image[1] * $percent); // Return as an html widht/height attribute $htmlWH = "width=\"" . $w . "\" height=\"" . $h . "\""; return $htmlWH; }