";
preg_match_all($pattern, $str, $out, PREG_PATTERN_ORDER);
$width = $out[2][0];
$height = $out[2][1];
$width2 = $out[2][2];
$height2 = $out[2][3];
if ($height > 150)
{
$height = 150;
$percent = ($height2 / $height);
$width = ($width2 / $percent);
}
else if ($width > 150)
{
$width = 150;
$percent = ($width2 / $width);
$height = ($height2 / $percent);
}
echo $width." ".$height."\n";
$pat[0] = '@width="([0-9]+)"@';
$pat[1] = '@height="([0-9]+)"@';
$rep[0] = 'width="'.$width.'"';
$rep[1] = 'height="'.$height.'"';
echo preg_replace($pat, $rep, $str);
?>