Thanks soooo much pig...
I had a few minor glitches in my coding, but nothing too difficult to figure out.
I really appriciate your direction on this!
Here is the working code incase anyone ever needs a similar solution:
$SetHeight = 100; //Establishes a Height Parameter of 100
$SetWidth = 135; //Establishes a Width Parameter of 135
$image_ = $a3; //The image data comes in from URL as $a3
$image_ = stripslashes($image_);
//Harvests the height=*** portion of $image_ and sets result to $H
preg_match("/height=([0-9]{1,} )/i", $image_, $matches);
$H = $matches[0];
//Harvests the numerical info from height= portion of $image_ and sets result to $H
preg_match("/([0-9]{1,})/", $H, $matches);
$H = $matches[0];
//Harvests the width=*** portion of $image_ and sets result to $W
preg_match("/width=([0-9]{1,} )/i", $image_, $matches);
$W = $matches[0];
//Harvests the numerical info from height= portion of $image_ and sets result to $H
preg_match("/([0-9]{1,})/", $W, $matches);
$W = $matches[0];
if (($H > $SetHeight) OR ($W > $SetWidth)) { //If $H or $W is larger than allowed...
if ($H > $W) { // check to see if $H of image is larger than $W
$ConstraintRatio = ($W / $H); // Figures out what constraint ratio is
$ConstraintRatio = round($ConstraintRatio, 4); // Rounds to x.xxxx
$W = ($SetHeight * $ConstraintRatio); // Finds new image width
$W = round($W); //Rounds to whole number
$H = $SetHeight; //Utilizes the $SetHeight as the $H
}
if ($W > $H) { // check to see if $W of image is larger than $H
$ConstraintRatio = ($H / $W); // Figures out what constraint ratio is
$ConstraintRAtio = round($ConstraintRatio, 4); // Rounds to x.xxxx
$H = ($SetWidth * $ConstraintRatio); // Finds new image height
$H = round($H); //Rounds to whole number
$W = $SetWidth; //Utilizes the $SetWidth as the $W
}
}
$newH = ("height=".$H." "); //gets height back into correct format
$newW = ("width=".$W." "); //gets width back into correct format
$image_ = preg_replace('/height=([0-9]{1,} )/i',$newH,$image_); // Replaces old height with new one
$image_ = preg_replace('/width=([0-9]{1,} )/i',$newW,$image_); // Replaces old width with new one
Thanks again!
Diana