I guess I should have said you could mark this closed/solved but I thought it was clear that the code I hacked was working to my satisfaction. I wanted to have the watermark scaled to fit the intermediate pic, or any uploaded full-size that is smaller than the max dimensions set for the gallery. Which is done just fine by the code already in your ModPack picmgmnt.inc.php. But I wanted a simple change so that the watermark was the same size for portrait and landscape. The code I wrote achieved that and works just fine.
However the code you just posted:
if ($wm_normal > max($destWidth, $destHeight) ) {
$wm_resize = max($destWidth, $destHeight) / $wm_normal;
works exactly the same as my much longer code:
if ($destWidth >= $destHeight) {
$destLongest = $destWidth;
} else {
$destLongest = $destHeight;
}
if ($wm_normal > $destWidth && $wm_normal > $destHeight ) {
$wm_resize = $destLongest / $wm_normal;
So you did teach me something new. I hadn't seen the "max" statement used before. Most of my limited knowledge of PHP comes from working with database apps. Simply adding and displaying data. Not much manipulation of data.
The nice thing about PHP is that there is usually more than one way to acieve the desired result. The challenge is sometimes to do it the best way!
I should say that I made a mistake when testing:
if ($wm_normal > $destWidth ) {
$wm_resize = $CONFIG['picture_width'] / $wm_normal;
When I commented out my code to test it I also commented a line that I shouldn't have.
That code actually worked the same as:
if ($wm_normal > $CONFIG['picture_width'] ) {
$wm_resize = $CONFIG['picture_width'] / $wm_normal;
Large and small, portrait and landscape all had the same size mark and the mark was scaled to fit the small pic.
Anyway... sorry to make you waste your time trying to help me when I had already done what I wanted. BUT thanks for the lesson in PHP! Your solution is much more elegant than my own.
Salute!