Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Image auto resize not working?

Image auto resize not working?

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nethelptutorialquestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    davebarkshire
    wrote on last edited by
    #1

    My projects in asp.net that show images do not resize in the browser if they are too big for the browser window. Most websites that I go to automatically resize the image if it's too big. So it's not the settings in the browser. Does anyone know why this happens or how to fix it? Thanks in advance - Dave

    J 1 Reply Last reply
    0
    • D davebarkshire

      My projects in asp.net that show images do not resize in the browser if they are too big for the browser window. Most websites that I go to automatically resize the image if it's too big. So it's not the settings in the browser. Does anyone know why this happens or how to fix it? Thanks in advance - Dave

      J Offline
      J Offline
      Jesse Squire
      wrote on last edited by
      #2

      Automatic image resizing to fit the window is indeed a browser setting. For Firefox it is under Tools-->Options-->Advanced-->Browsing. For IE it is under Tools-->Internet Options-->Advanced-->Multimedia. You can, however, control the image size using the CSS height[^] and width[^] properties. The first possible solution that comes to mind would be to handle the javascript onload and resize events to sniff the browser dimentions and set the image size accordingly. Hope that helps. :) --Jesse

      D 1 Reply Last reply
      0
      • J Jesse Squire

        Automatic image resizing to fit the window is indeed a browser setting. For Firefox it is under Tools-->Options-->Advanced-->Browsing. For IE it is under Tools-->Internet Options-->Advanced-->Multimedia. You can, however, control the image size using the CSS height[^] and width[^] properties. The first possible solution that comes to mind would be to handle the javascript onload and resize events to sniff the browser dimentions and set the image size accordingly. Hope that helps. :) --Jesse

        D Offline
        D Offline
        davebarkshire
        wrote on last edited by
        #3

        Jesse Thanks for the reply. I hadn't really thought about doing it manually but it would be a possible solution. I just can't understand why pictures from other sites resize automatically whereas by pictures don't. I'm using asp.net to render an image programatically. Here is a picture from a normal website that resises automatically http://www.barkshire.co.uk/bikes/images/Norton18_1931/NortonMod18_1931_RL_low.jpg[^] and here is one from the dot net project that doesn't http://www.barkshire.co.uk/travel/ShowSingle.aspx?URL=Angkor_tree1.jpg[^] There must be something in the way that its streamed down. I wish that there was a client side method that would call the automatic resize. Dave

        D S 2 Replies Last reply
        0
        • D davebarkshire

          Jesse Thanks for the reply. I hadn't really thought about doing it manually but it would be a possible solution. I just can't understand why pictures from other sites resize automatically whereas by pictures don't. I'm using asp.net to render an image programatically. Here is a picture from a normal website that resises automatically http://www.barkshire.co.uk/bikes/images/Norton18_1931/NortonMod18_1931_RL_low.jpg[^] and here is one from the dot net project that doesn't http://www.barkshire.co.uk/travel/ShowSingle.aspx?URL=Angkor_tree1.jpg[^] There must be something in the way that its streamed down. I wish that there was a client side method that would call the automatic resize. Dave

          D Offline
          D Offline
          davebarkshire
          wrote on last edited by
          #4

          I nearly forgot... The icon in the bottom right corner that usually appears with oversized images does not appear! The browser must think that it's something else because the src attribute of the image tag points to an aspx page.

          J 1 Reply Last reply
          0
          • D davebarkshire

            Jesse Thanks for the reply. I hadn't really thought about doing it manually but it would be a possible solution. I just can't understand why pictures from other sites resize automatically whereas by pictures don't. I'm using asp.net to render an image programatically. Here is a picture from a normal website that resises automatically http://www.barkshire.co.uk/bikes/images/Norton18_1931/NortonMod18_1931_RL_low.jpg[^] and here is one from the dot net project that doesn't http://www.barkshire.co.uk/travel/ShowSingle.aspx?URL=Angkor_tree1.jpg[^] There must be something in the way that its streamed down. I wish that there was a client side method that would call the automatic resize. Dave

            S Offline
            S Offline
            Scott Serl
            wrote on last edited by
            #5

            The reason is: The first link is not a web page (it is a .jpg file, not .html) and the second link is a we page (it is .aspx file, not .jpg). Your browser automatically resizes image files to fit. The browser must be told by your web page how the image should be displayed.

            D 1 Reply Last reply
            0
            • D davebarkshire

              I nearly forgot... The icon in the bottom right corner that usually appears with oversized images does not appear! The browser must think that it's something else because the src attribute of the image tag points to an aspx page.

              J Offline
              J Offline
              Jesse Squire
              wrote on last edited by
              #6

              Yup... Scott nailed it. Remember that it is a browser setting, not an HTML/ASP.NET behavior to resize images. The browser appears to apply the behavior based on the file extension, rather then the conten headers. As it is a browser setting, controlled by the users, you may want to be careful depending on it. Some users, such as myself, turn the feature off. If you need to depend on it, you'll have to scale the image manually. Hope that helps. :) --Jesse

              1 Reply Last reply
              0
              • S Scott Serl

                The reason is: The first link is not a web page (it is a .jpg file, not .html) and the second link is a we page (it is .aspx file, not .jpg). Your browser automatically resizes image files to fit. The browser must be told by your web page how the image should be displayed.

                D Offline
                D Offline
                davebarkshire
                wrote on last edited by
                #7

                Thanks for the help from you all. it does make sense now that i think about it more. I have only one final question. Does anyone have a snippet of javascript or asp.net code that will resize the image?

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups