Image Question
if ( ($width <= $max_width) && ($height <= $max_height) ) {
$tn_width = $width;
$tn_height = $height;
}
else if (($x_ratio * $height) < $max_height) {
$tn_height = ceil($x_ratio * $height);
$tn_width = $max_width;
}
else {
$tn_width = ceil($y_ratio * $width);
$tn_height = $max_height;
}
Ok, I understand the whole image resizing thing EXCEPT for this part. This was taken out of a book I've been working with.
Basically, if the image is bigger than the allotted maxheight/maxwidth, the elses are executed.
The x_ratio is the max_width/original_width, and vice versa.
The thing I don't get is, WHY is the HEIGHT multiplied by the WIDTH'S percentage to be checked in the else statement?
If you want to resize proportionately, why would you mix the width scale with the height instead of using the y_ratio with the height?
Any help would be appreciated, and sorry for the newb question. :P
$tn_width = $width;
$tn_height = $height;
}
else if (($x_ratio * $height) < $max_height) {
$tn_height = ceil($x_ratio * $height);
$tn_width = $max_width;
}
else {
$tn_width = ceil($y_ratio * $width);
$tn_height = $max_height;
}
Ok, I understand the whole image resizing thing EXCEPT for this part. This was taken out of a book I've been working with.
Basically, if the image is bigger than the allotted maxheight/maxwidth, the elses are executed.
The x_ratio is the max_width/original_width, and vice versa.
The thing I don't get is, WHY is the HEIGHT multiplied by the WIDTH'S percentage to be checked in the else statement?
If you want to resize proportionately, why would you mix the width scale with the height instead of using the y_ratio with the height?
Any help would be appreciated, and sorry for the newb question. :P
