I know how to get the size of an image via Image::Info, but I want to add a little snippet that does a little more.

I have a picture posting site where users can upload images to and some are too large and ends up making horizontal scrollbards on the browser (not acceptable!). I can now detect which images are larger than 800x600, which is what I want to test against, but how can I dynamically resize the HTML renderation of the image?

I'm NOT trying to resize the image itself, just the HTML code of the image. Ie. <code> I'm just using HTML to make it appear smaller on screen so the user can click the image to make it appear full in a new window.

So let's say the image was 1100x900, I want to use the HTML image size to show the image at the first size in which both dimensions are smaller than my required size (800x600). In short, I want the resize to be proportioned to the size of the image itself. I COULD just resize everything that's too large to 800x600 but that'd cause a lot of crappy images, I want to keep the same proportions.

Can anyone help me with this?


In reply to determining size of image by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.