Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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, 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, 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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Domain Nodelet?
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this?Last hourOther CB clients
    Other Users?
    Others goofing around in the Monastery: (7)
    As of 2024-07-24 12:51 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found

      Notices?
      erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.