public function testRectangle() {
		// Normal scaling with preserved aspect ratio.
		list($width, $height) = Resize::rectangle(560, 250, 480, 0);
		$this->assertEquals(215, $height);
		list($width, $height) = Resize::rectangle(256, 128, 0, 500);
		$this->assertEquals(1000, $width);
		
		// Enforce target dimensions (skewing the rectangle).
		$this->assertEquals(array(500, 400), Resize::rectangle(800, 600, 500, 400));
		
		// Test IF_*.
		list($width, $height) = Resize::rectangle(800, 600, 480, 0, Resize::IF_SMALLER);
		$this->assertEquals(600, $height);
		list($width, $height) = Resize::rectangle(480, 320, 800, 0, Resize::IF_BIGGER);
		$this->assertEquals(320, $height);
	}
	/**
	 * Resize an embed tag by matching all width/height
	 * attributes in the given $markup, using the first pair
	 * to calculate new width/height values and then replacing
	 * the old attributes. This method is quite dumb and will
	 * not handle unexpected or complicated markup well.
	 * 
	 * @param string $markup
	 * @param integer $width
	 * @param integer $height
	 * @param integer $when
	 * 
	 * @return string
	 */
	public static function using_attributes($markup, $width, $height,
			$when = Resize::ALWAYS) {
		// These two variable names must match the two keys in the
		// $search array below.
		$attrWidth = 0;
		$attrHeight = 0;
		
		// Regexes to match width and height attributes in markup.
		$search = array(
			'attrWidth' => '/width(\s*)=\1"?\d+"?/i',
			'attrHeight' => '/height(\s*)=\1"?\d+"?/i'
		);
		
		$matches = array();
		
		// Find all width and height attributes in the markup given.
		foreach ($search as $key => $pattern) {
			if (preg_match($pattern, $markup, $matches))
				if (preg_match('/\d+/i', $matches[0], $matches))
					$$key = $matches[0];
		}
		list($width, $height) = Resize::rectangle($attrWidth, $attrHeight, $width, $height, $when);
		$replace = array(
			"width=\"{$width}\"",
			"height=\"{$height}\""
		);
		
		$markup = strip_tags($markup, '<iframe><object><param><embed><video>');
		$markup = preg_replace($search, $replace, $markup);
		
		return $markup;
	}