Client-side function to resize ".jpg" images

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Don

    Client-side function to resize ".jpg" images

    Does anyone know where I can find a client-side function I can reference from within an
    HTML/JavaScript web page? I'm currently using a core PHP function to do this, but I'd rather do it
    on the client-side and not have to upload the large raw image to the server.

    Thanks in advance for your help.
    Don


    ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
    ---= East/West-Coast Server Farms - Total Privacy via Encryption =---
  • Andrew Thompson

    #2
    Re: Client-side function to resize ".jpg&quot ; images

    On Thu, 18 Nov 2004 10:42:57 -0700, Don wrote:
    [color=blue]
    > Does anyone know where I can find a client-side function I can reference from within an
    > HTML/JavaScript web page? I'm currently using a core PHP function to do this, but I'd rather do it
    > on the client-side and not have to upload the large raw image to the server.[/color]

    So instead you want to upload a 400Kb image, serve that 400Kb
    to your users, and have a client-side solution to rescale the
    image to a smaller size (that could have been served in 100Kb)?

    That is insane.

    And, no. Certainly not in any reliable, crossbrowser way
    using JS, but it is possible (very poorly) using HTML.

    --
    Andrew Thompson
    http://www.PhySci.org/codes/ Web & IT Help
    http://www.PhySci.org/ Open-source software suite
    http://www.1point1C.org/ Science & Technology
    http://www.LensEscapes.com/ Images that escape the mundane

    Comment

    • Don

      #3
      Re: Client-side function to resize ".jpg&quot ; images

      On Fri, 19 Nov 2004 00:18:32 GMT, Andrew Thompson <SeeMySites@www .invalid> wrote:
      [color=blue]
      >On Thu, 18 Nov 2004 10:42:57 -0700, Don wrote:
      >[color=green]
      >> Does anyone know where I can find a client-side function I can reference from within an
      >> HTML/JavaScript web page? I'm currently using a core PHP function to do this, but I'd rather do it
      >> on the client-side and not have to upload the large raw image to the server.[/color]
      >
      >So instead you want to upload a 400Kb image, serve that 400Kb
      >to your users, and have a client-side solution to rescale the
      >image to a smaller size (that could have been served in 100Kb)?
      >
      >That is insane.
      >
      >And, no. Certainly not in any reliable, crossbrowser way
      >using JS, but it is possible (very poorly) using HTML.[/color]
      Andrew,

      Thanks for your response. But, you kinda got it all wrong. I want a client-side function to which
      I can submit a client camera size image (3 megapixel, etc.) and have it resized to 700 pixels wide
      at a ".jpg" compression-level that results in a file size around 100 KB. Then, I want to take that
      and ship it off to my PHP script running on the server. That script then puts the 100 KB image in a
      PictureVault folder. Users can then access pictures in the PictureVault. I'm already doing this,
      except I take their 3 megapixel picture and immediately upload it to the PHP script. I want to cut
      down on the bandwidth (transfer rate) on the server end.

      Don


      ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
      http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
      ---= East/West-Coast Server Farms - Total Privacy via Encryption =---

      Comment

      • Andrew Thompson

        #4
        Re: Client-side function to resize &quot;.jpg&quot ; images

        On Thu, 18 Nov 2004 20:28:36 -0700, Don wrote:
        [color=blue]
        > Thanks for your response. But, you kinda
        > got it all wrong. I want a client-side function ...[/color]

        (slaps forehead) D'uhh! Just like you said in your
        opening sentence, ..and subject. *Still* I completely
        missed it.

        My bad. Sorry for wasting the bandwidth.

        No, I don't have a solution to the stated problem.

        Though, (musing)..

        I imagine that while their might be an ActiveX object for
        IE that will do this in a (possibly signed) script(/HTA),
        it would not be cross-browser. [ You'll need to consult
        the JS experts on that. ]

        OTOH, you might look to a signed Java applet (though note
        that Java is a separate language to Javascript, and requires
        the Java Plug-In from Sun).

        HTH

        --
        Andrew Thompson
        http://www.PhySci.org/codes/ Web & IT Help
        http://www.PhySci.org/ Open-source software suite
        http://www.1point1C.org/ Science & Technology
        http://www.LensEscapes.com/ Images that escape the mundane

        Comment

        • J. J. Cale

          #5
          Re: Client-side function to resize &quot;.jpg&quot ; images

          you can just insert the smaller height and/or width into the img tag
          <img name="imgName" id="imgId" src="pic.jpg" width="120">

          or change it programmaticall y e.g. through the onload event in the body tag
          <body onload="changeS ize()">
          <script type="text/javascript">
          function changeSize() {
          // not tested
          // get a reference to the image by whatever standards you wish to support
          var obj = document.images['imgName']; // pretty safe
          obj.style.width ='140px';
          </script>
          HTH
          Jimbo
          "Don" <no@adr.com> wrote in message
          news:ginpp09nqp 28s3sic8gp0ubla 1uoho043d@4ax.c om...[color=blue]
          > Does anyone know where I can find a client-side function I can reference[/color]
          from within an[color=blue]
          > HTML/JavaScript web page? I'm currently using a core PHP function to do[/color]
          this, but I'd rather do it[color=blue]
          > on the client-side and not have to upload the large raw image to the[/color]
          server.[color=blue]
          >
          > Thanks in advance for your help.
          > Don
          >
          >
          > ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet[/color]
          News==----[color=blue]
          > http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000[/color]
          Newsgroups[color=blue]
          > ---= East/West-Coast Server Farms - Total Privacy via Encryption =---[/color]


          Comment

          • lawrence

            #6
            Re: Client-side function to resize &quot;.jpg&quot ; images

            Andrew Thompson <SeeMySites@www .invalid> wrote in message news:<gtlu71r0x ywo.1xbfi666itk af$.dlg@40tude. net>...[color=blue]
            > I imagine that while their might be an ActiveX object for
            > IE that will do this in a (possibly signed) script(/HTA),
            > it would not be cross-browser. [ You'll need to consult
            > the JS experts on that. ]
            >
            > OTOH, you might look to a signed Java applet (though note
            > that Java is a separate language to Javascript, and requires
            > the Java Plug-In from Sun).[/color]

            There must already be a Java plug-in that does it, since it is such a
            common need. But if not, I've been thinking about writing one to work
            with my own PHP CMS. One of the most frequent requests I get is people
            who take a picture with their digital camera and then upload and then
            complain to me that it is way to big on the web site (16 inches wide,
            or so).

            Comment

            • Randy Webb

              #7
              Re: Client-side function to resize &quot;.jpg&quot ; images

              lawrence wrote:
              [color=blue]
              > Andrew Thompson <SeeMySites@www .invalid> wrote in message news:<gtlu71r0x ywo.1xbfi666itk af$.dlg@40tude. net>...
              >[color=green]
              >>I imagine that while their might be an ActiveX object for
              >>IE that will do this in a (possibly signed) script(/HTA),
              >>it would not be cross-browser. [ You'll need to consult
              >>the JS experts on that. ]
              >>
              >>OTOH, you might look to a signed Java applet (though note
              >>that Java is a separate language to Javascript, and requires
              >>the Java Plug-In from Sun).[/color]
              >
              >
              > There must already be a Java plug-in that does it, since it is such a
              > common need. But if not, I've been thinking about writing one to work
              > with my own PHP CMS. One of the most frequent requests I get is people
              > who take a picture with their digital camera and then upload and then
              > complain to me that it is way to big on the web site (16 inches wide,
              > or so).[/color]

              It would be easier, simpler, and more productive to create a page that
              explains how to resize images in image-editing software.

              --
              Randy
              comp.lang.javas cript FAQ - http://jibbering.com/faq

              Comment

              • Randy Webb

                #8
                Re: Client-side function to resize &quot;.jpg&quot ; images

                J. J. Cale wrote:
                [color=blue]
                > you can just insert the smaller height and/or width into the img tag
                > <img name="imgName" id="imgId" src="pic.jpg" width="120">
                >[/color]

                And how exactly does that change the physical size of the image? Which
                is what the OP wanted and your img tag fails to do.

                [color=blue]
                > or change it programmaticall y e.g. through the onload event in the body tag
                > <body onload="changeS ize()">
                > <script type="text/javascript">
                > function changeSize() {
                > // not tested
                > // get a reference to the image by whatever standards you wish to support
                > var obj = document.images['imgName']; // pretty safe
                > obj.style.width ='140px';
                > </script>[/color]

                See Above.

                Read the group FAQ, as linked to in my signature.

                --
                Randy
                comp.lang.javas cript FAQ - http://jibbering.com/faq
                Answer:It destroys the order of the conversation
                Question: Why?
                Answer: Top-Posting.
                Question: Whats the most annoying thing on Usenet?

                Comment

                • J. J. Cale

                  #9
                  Re: Client-side function to resize &quot;.jpg&quot ; images


                  "Randy Webb" <HikksNotAtHome @aol.com> wrote in message
                  news:GNqdnb6Od6 DEsgPcRVn-gA@comcast.com. ..[color=blue]
                  > J. J. Cale wrote:
                  >[color=green]
                  > > you can just insert the smaller height and/or width into the img tag
                  > > <img name="imgName" id="imgId" src="pic.jpg" width="120">
                  > >[/color]
                  >
                  > And how exactly does that change the physical size of the image? Which
                  > is what the OP wanted and your img tag fails to do.[/color]

                  I believe the OP just wanted to display the image at a smaller size, and not
                  actually resize the image.
                  [color=blue][color=green]
                  > > or change it programmaticall y e.g. through the onload event in the body[/color][/color]
                  tag[color=blue][color=green]
                  > > <body onload="changeS ize()">
                  > > <script type="text/javascript">
                  > > function changeSize() {
                  > > // not tested
                  > > // get a reference to the image by whatever standards you wish to[/color][/color]
                  support[color=blue][color=green]
                  > > var obj = document.images['imgName']; // pretty safe
                  > > obj.style.width ='140px';
                  > > </script>[/color]
                  >
                  > See Above.
                  >
                  > Read the group FAQ, as linked to in my signature.
                  >
                  > --
                  > Randy
                  > comp.lang.javas cript FAQ - http://jibbering.com/faq
                  > Answer:It destroys the order of the conversation
                  > Question: Why?
                  > Answer: Top-Posting.
                  > Question: Whats the most annoying thing on Usenet?[/color]


                  Comment

                  • Randy Webb

                    #10
                    Re: Client-side function to resize &quot;.jpg&quot ; images

                    J. J. Cale wrote:[color=blue]
                    > "Randy Webb" <HikksNotAtHome @aol.com> wrote in message
                    > news:GNqdnb6Od6 DEsgPcRVn-gA@comcast.com. ..
                    >[color=green]
                    >>J. J. Cale wrote:
                    >>
                    >>[color=darkred]
                    >>>you can just insert the smaller height and/or width into the img tag
                    >>><img name="imgName" id="imgId" src="pic.jpg" width="120">
                    >>>[/color]
                    >>And how exactly does that change the physical size of the image? Which
                    >>is what the OP wanted and your img tag fails to do.[/color]
                    >
                    >
                    > I believe the OP just wanted to display the image at a smaller size, and not
                    > actually resize the image.[/color]

                    Perhaps, but this part of the post:
                    <quote>
                    I'm currently using a core PHP function to do this, but I'd rather do
                    it on the client-side and not have to upload the large raw image to the
                    server.
                    </quote>

                    Implies, to me, that they are using the image functions in PHP to resize
                    it after upload. If the only purpose to resizing it, prior to upload, is
                    to alter its display in the browser, I don't see the purpose of doing that.

                    However, if resizing it (physically) prior to upload is the desire, it
                    makes good sense to me.

                    --
                    Randy
                    comp.lang.javas cript FAQ - http://jibbering.com/faq

                    Comment

                    Working...