thanks for the tips on images. i will be depending on gd lib. what the heck is WAP format? am i correct in thinking that imagecreatefromwbmp doesn't work on windows bitmaps? am i also correct in thinking that gd lib can't help me with TIFs or windows bitmaps?
as for the resizing reasoning, i'm a bit confused by your code. consider an image that is 600w x 1800h. my maxes are:
define('MAX_WIDTH', 600);
define('MAX_HEIGHT', 1200);
so in your example:
$width_difference = MAX_WIDTH-$width; // returns 0
$height_difference = MAX_HEIGHT-$height; // returns -600
$scaling_factor = ($height_difference > $width_difference) // false
? MAX_HEIGHT/$height // no
: MAX_WIDTH/$width; // yes, returns 1 -- no good
it occurred to me that you might have just switched the subtract sequence but i still think it doesn't work. consider an image 1199w x 1800 h
$width_difference = $width - MAX_WIDTH; // returns 599
$height_difference = $height - MAX_HEIGHT; // returns 600
$scaling_factor = ($height_difference > $width_difference) // true
? MAX_HEIGHT/$height // yes, returns 0.6667
: MAX_WIDTH/$width; // no
$new_height = intval($height*$scaling_factor); // returns 1200 which is great!
$new_width = intval($width*$scaling_factor); // returns 799 which is *too wide*
my original thinking with the logic was basically that if either width or height requires scaling down, it is the lower scaling factor because one is 100% and the other must be scaled.
when both need rescaling, it is the more extreme rescaling we should use because otherwise that dimension will not be sufficiently scaled down. i can't prove it mathematically though and i'm not sure my logic accomplishes that. it's bugging me.