How to limit an image size to AxB?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • http://links.i6networks.com

    How to limit an image size to AxB?

    I need to display pictures, but only as large as AxB. If it is smaller than
    AxB, then I will display it in the original size, if it is larger than AxB,
    I will resize it.

    However, if the size is 100x200, but I limited it to 50x60, then if I use
    height x width, the image does not display well. So, I want it to srink is a
    ratio of the original size, so it is will be from 100x200 to 30x60.

    How can I do it if it is hosted on my server, -- Any server side image
    program to change sizes?

    How can I do it if it is hosted remoted, and I only use the src hot link, --
    so I must find a way to do it in Javascript to resize it.


  • Charles Sweeney

    #2
    Re: How to limit an image size to AxB?

    http://links.i6networks.com wrote:

    You are a fucking nuiscance.

    --
    Charles Sweeney

    Comment

    • atec

      #3
      Re: How to limit an image size to AxB?



      Charles Sweeney wrote:[color=blue]
      >
      > http://links.i6networks.com wrote:
      >
      > You are a fucking nuiscance.[/color]


      how did you determine that sweeney ?. (:P)[color=blue]
      >
      > --
      > Charles Sweeney
      > http://CharlesSweeney.com[/color]

      --
      X-No-Archive: Yes

      Comment

      • Evertjan.

        #4
        Re: How to limit an image size to AxB?

        http://links.i6networks.com wrote on 16 aug 2004 in
        comp.lang.javas cript:
        [color=blue]
        > I need to display pictures, but only as large as AxB. If it is smaller
        > than AxB, then I will display it in the original size, if it is larger
        > than AxB, I will resize it.
        >
        > However, if the size is 100x200, but I limited it to 50x60, then if I
        > use height x width, the image does not display well. So, I want it to
        > srink is a ratio of the original size, so it is will be from 100x200
        > to 30x60.
        >
        > How can I do it if it is hosted on my server, -- Any server side image
        > program to change sizes?[/color]

        Depends on your serverside platform, under ASP you would need a com
        object I suppose. OT here.
        [color=blue]
        > How can I do it if it is hosted remoted, and I only use the src hot
        > link, -- so I must find a way to do it in Javascript to resize it.[/color]

        Only IE tested:

        <img id="pp" src="my.gif">

        <script>
        p = document.getEle mentById("pp")
        w = p.clientWidth
        h = p.clientHeight
        // max 50x60
        if (w>50||h>60){
        if (w/h>50/60){
        p.style.width=' 50px'
        alert("width corrected, relative aspect kept")
        } else {
        p.style.height= '60px'
        alert("height corrected, relative aspect kept")
        }
        } else {
        alert("no correction, is small enough")
        }
        </script>


        --
        Evertjan.
        The Netherlands.
        (Please change the x'es to dots in my emailaddress)

        Comment

        • Charles Sweeney

          #5
          Re: How to limit an image size to AxB?

          atec wrote:
          [color=blue]
          >
          >
          > Charles Sweeney wrote:[color=green]
          >>
          >> http://links.i6networks.com wrote:
          >>
          >> You are a fucking nuiscance.[/color]
          >
          >
          > how did you determine that sweeney ?. (:P)[/color]

          Strangely enough Mary, in much the same way you are.

          --
          Charles Sweeney

          Comment

          • atec

            #6
            Re: How to limit an image size to AxB?



            Charles Sweeney wrote:[color=blue]
            >
            > atec wrote:
            >[color=green]
            > >
            > >
            > > Charles Sweeney wrote:[color=darkred]
            > >>
            > >> http://links.i6networks.com wrote:
            > >>
            > >> You are a fucking nuiscance.[/color]
            > >
            > >
            > > how did you determine that sweeney ?. (:P)[/color]
            >
            > Strangely enough Mary, in much the same way you are.[/color]
            Marty , me ?.
            whoosh sweeny , whoosh[color=blue]
            >
            > --
            > Charles Sweeney
            > http://CharlesSweeney.com[/color]

            --
            X-No-Archive: Yes

            Comment

            • Charles Sweeney

              #7
              Re: How to limit an image size to AxB?

              atec wrote:
              [color=blue]
              >
              >
              > Charles Sweeney wrote:[color=green]
              >>
              >> atec wrote:
              >>[color=darkred]
              >> >
              >> >
              >> > Charles Sweeney wrote:
              >> >>
              >> >> http://links.i6networks.com wrote:
              >> >>
              >> >> You are a fucking nuiscance.
              >> >
              >> >
              >> > how did you determine that sweeney ?. (:P)[/color]
              >>
              >> Strangely enough Mary, in much the same way you are.[/color]
              > Marty , me ?.
              > whoosh sweeny , whoosh[/color]

              Good girl.

              --
              Charles Sweeney

              Comment

              • atec

                #8
                Re: How to limit an image size to AxB?



                Charles Sweeney wrote:[color=blue]
                >
                > atec wrote:
                >[color=green]
                > >
                > >
                > > Charles Sweeney wrote:[color=darkred]
                > >>
                > >> atec wrote:
                > >>
                > >> >
                > >> >
                > >> > Charles Sweeney wrote:
                > >> >>
                > >> >> http://links.i6networks.com wrote:
                > >> >>
                > >> >> You are a fucking nuiscance.
                > >> >
                > >> >
                > >> > how did you determine that sweeney ?. (:P)
                > >>
                > >> Strangely enough Mary, in much the same way you are.[/color]
                > > Marty , me ?.
                > > whoosh sweeny , whoosh[/color]
                >
                > Good girl.[/color]
                aha , you pat your self eh ?. now remind us what that's called .[color=blue]
                >
                > --
                > Charles Sweeney
                > http://CharlesSweeney.com[/color]

                --
                X-No-Archive: Yes

                Comment

                • Gregory Toomey

                  #9
                  Re: How to limit an image size to AxB?

                  http://links.i6networks.com wrote:
                  [color=blue]
                  > I need to display pictures, but only as large as AxB. If it is smaller
                  > than AxB, then I will display it in the original size, if it is larger
                  > than AxB, I will resize it.[/color]

                  Read http://www.catb.org/~esr/faqs/smart-questions.html
                  before asking innane quesions.

                  gtoomey

                  Comment

                  • Michael Winter

                    #10
                    Re: How to limit an image size to AxB?

                    [Follow-ups set to alt.flame]

                    On Mon, 16 Aug 2004 atec <"atec77(notspa m)"@hotmail.com > and Charles
                    Sweeney <me@charlesswee ney.com> were both jackasses:

                    [snipped rubbish]

                    Will you please take this a more appropriate group or e-mail.

                    Mike

                    --
                    Michael Winter
                    Replace ".invalid" with ".uk" to reply by e-mail

                    Comment

                    • Charles Sweeney

                      #11
                      Re: How to limit an image size to AxB?

                      Michael Winter wrote:
                      [color=blue]
                      > [Follow-ups set to alt.flame]
                      >
                      > On Mon, 16 Aug 2004 atec <"atec77(notspa m)"@hotmail.com > and Charles
                      > Sweeney <me@charlesswee ney.com> were both jackasses:
                      >
                      > [snipped rubbish]
                      >
                      > Will you please take this a more appropriate group or e-mail.
                      >
                      > Mike[/color]

                      I didn't realise this was going to comp.lang.javas cript

                      If you were regular in AWW you would know that there are certain issues
                      between me and the "atec" character.

                      Therefore my initial feeling that you are a total wanker, is slightly
                      off.

                      --
                      Charles Sweeney

                      Comment

                      • atec

                        #12
                        Re: How to limit an image size to AxB?



                        Charles Sweeney wrote:[color=blue]
                        >
                        > Michael Winter wrote:
                        >[color=green]
                        > > [Follow-ups set to alt.flame]
                        > >
                        > > On Mon, 16 Aug 2004 atec <"atec77(notspa m)"@hotmail.com > and Charles
                        > > Sweeney <me@charlesswee ney.com> were both jackasses:
                        > >
                        > > [snipped rubbish]
                        > >
                        > > Will you please take this a more appropriate group or e-mail.
                        > >
                        > > Mike[/color]
                        >
                        > I didn't realise this was going to comp.lang.javas cript
                        >
                        > If you were regular in AWW you would know that there are certain issues
                        > between me and the "atec" character.
                        >
                        > Therefore my initial feeling that you are a total wanker, is slightly
                        > off.[/color]
                        no issues his end sweeny[color=blue]
                        >
                        > --
                        > Charles Sweeney
                        > http://CharlesSweeney.com[/color]

                        --
                        X-No-Archive: Yes

                        Comment

                        • http://links.i6networks.com

                          #13
                          Re: How to limit an image size to AxB?

                          Extremely smart. Thanks.
                          [color=blue]
                          > http://links.i6networks.com wrote on 16 aug 2004 in
                          > comp.lang.javas cript:
                          >[color=green]
                          > > I need to display pictures, but only as large as AxB. If it is smaller
                          > > than AxB, then I will display it in the original size, if it is larger
                          > > than AxB, I will resize it.
                          > >
                          > > However, if the size is 100x200, but I limited it to 50x60, then if I
                          > > use height x width, the image does not display well. So, I want it to
                          > > srink is a ratio of the original size, so it is will be from 100x200
                          > > to 30x60.
                          > >
                          > > How can I do it if it is hosted on my server, -- Any server side image
                          > > program to change sizes?[/color]
                          >
                          > Depends on your serverside platform, under ASP you would need a com
                          > object I suppose. OT here.
                          >[color=green]
                          > > How can I do it if it is hosted remoted, and I only use the src hot
                          > > link, -- so I must find a way to do it in Javascript to resize it.[/color]
                          >
                          > Only IE tested:
                          >
                          > <img id="pp" src="my.gif">
                          >
                          > <script>
                          > p = document.getEle mentById("pp")
                          > w = p.clientWidth
                          > h = p.clientHeight
                          > // max 50x60
                          > if (w>50||h>60){
                          > if (w/h>50/60){
                          > p.style.width=' 50px'
                          > alert("width corrected, relative aspect kept")
                          > } else {
                          > p.style.height= '60px'
                          > alert("height corrected, relative aspect kept")
                          > }
                          > } else {
                          > alert("no correction, is small enough")
                          > }
                          > </script>
                          >
                          >
                          > --
                          > Evertjan.
                          > The Netherlands.
                          > (Please change the x'es to dots in my emailaddress)[/color]


                          Comment

                          • Harag

                            #14
                            Re: How to limit an image size to AxB?

                            On 16 Aug 2004 09:28:25 GMT, "Evertjan."
                            <exjxw.hannivoo rt@interxnl.net > wrote:
                            [color=blue]
                            >http://links.i6networks.com wrote on 16 aug 2004 in
                            >comp.lang.java script:
                            >[color=green]
                            >> I need to display pictures, but only as large as AxB. If it is smaller
                            >> than AxB, then I will display it in the original size, if it is larger
                            >> than AxB, I will resize it.
                            >>
                            >> However, if the size is 100x200, but I limited it to 50x60, then if I
                            >> use height x width, the image does not display well. So, I want it to
                            >> srink is a ratio of the original size, so it is will be from 100x200
                            >> to 30x60.
                            >>
                            >> How can I do it if it is hosted on my server, -- Any server side image
                            >> program to change sizes?[/color]
                            >
                            >Depends on your serverside platform, under ASP you would need a com
                            >object I suppose. OT here.
                            >[color=green]
                            >> How can I do it if it is hosted remoted, and I only use the src hot
                            >> link, -- so I must find a way to do it in Javascript to resize it.[/color]
                            >
                            >Only IE tested:
                            >
                            ><img id="pp" src="my.gif">
                            >
                            ><script>
                            >p = document.getEle mentById("pp")
                            >w = p.clientWidth
                            >h = p.clientHeight
                            >// max 50x60
                            >if (w>50||h>60){
                            > if (w/h>50/60){
                            > p.style.width=' 50px'
                            > alert("width corrected, relative aspect kept")
                            > } else {
                            > p.style.height= '60px'
                            > alert("height corrected, relative aspect kept")
                            > }
                            >} else {
                            > alert("no correction, is small enough")
                            >}
                            ></script>[/color]


                            Image Elements have a "width" & "height" properties (according to the
                            book I'm reading, Javascript: The Difinitive Guide)

                            Maybe using the getElementsByNa me() method might be of use.

                            <img name="thumbnail " src="pic1.gif>
                            <img name="thumbnail " src="pic2.gif>
                            <img name="thumbnail " src="pic3.gif>

                            <script>
                            var maxWidth=50, maxHeight=60;
                            var imgs = document.getEle mentsByName("th umbnail");
                            if (imgs.length >0) {
                            for (var i = 0; i < imgs.length; i++) {
                            if (imgs[i].width > maxWidth || img[i].height > maxHeight) {
                            imgs[i].width = maxWidth;
                            imgs[i].height = maxHeight;
                            }
                            }
                            }
                            </script>


                            (note untested code) and that I'm no expert so don't even know if the
                            above will work :P

                            HTH

                            Al.


                            Comment

                            • Evertjan.

                              #15
                              Re: How to limit an image size to AxB?

                              Harag wrote on 16 aug 2004 in comp.lang.javas cript:
                              [color=blue]
                              > if (imgs[i].width > maxWidth || img[i].height > maxHeight) {
                              > imgs[i].width = maxWidth;
                              > imgs[i].height = maxHeight;
                              > }
                              >[/color]

                              This will deform the pictures !

                              Please review my code.

                              --
                              Evertjan.
                              The Netherlands.
                              (Please change the x'es to dots in my emailaddress)

                              Comment

                              Working...