in reply to Re: Dealing with rectangular images
in thread Dealing with rectangular images

Sorry, maybe I wasn't clear. I'm resizing via css so I'm not worried about that. BUT, I'd like to either use a gray background to letterbox the wide images, or display the image above the title if it is too wide. I'm using this but it's not working all the time:
if ($picwidth / $picheight > 1.5) { $backcolor="#f5f5f5"; } else { $backcolor="#ffffff"; }
So I divide the width by the height and if it's greater than 1.5 it should display the gray color. Some pics that the calculation equals 1.77 do not trigger the gray though. I might be doing it wrong.

Replies are listed 'Best First'.
Re^3: Dealing with rectangular images
by pryrt (Abbot) on May 25, 2016 at 20:57 UTC

    What are the values of $picwidth and $picheight that do and don't work?

    When I wrapped it in a loop to try a handful of ratios, I couldn't find any that didn't. That's why How do I post a question effectively recommends providing actual code with data that evidences the problem.

    OUTPUT:

Re^3: Dealing with rectangular images
by RonW (Parson) on May 26, 2016 at 00:48 UTC
    I'm resizing via css

    That's generally not a good idea. Images that are too big the for target display area are a waste of resources. High speed connections often aren't. And even now, a lot of people have underpowered GPUs. Also, even a small difference in size will add up, pushing up your bandwidth usage as well as your customers.

    The end result is usually much better when you tell the customers the sizes of the image areas. At very least, you avoid customer dismay when they see what your system has done to their images.