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. Resizing Image

Resizing Image

Scheduled Pinned Locked Moved ASP.NET
database
4 Posts 2 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.
  • A Offline
    A Offline
    Avanika Gupta
    wrote on last edited by
    #1

    Hi All, I have a web page which is having repeater control which in turn have image control.I am setting the ImageUrl property of the image control during runtime in the ItemDatabound event of the Repeater control ( because image is being retrieved from the SQL database). I am setting the height and width property as well during runtime. Doing this I am able to see the resized image on the web page, but when I export this to MS Word, I am seeing the image in the word document with original dimensions. I need the word document to have the image in the same dimensions as I can see in the web page. Basically I am trying to generate the report in word format which would be exactly the same as that of the web page. Thanks, Avanika

    M 1 Reply Last reply
    0
    • A Avanika Gupta

      Hi All, I have a web page which is having repeater control which in turn have image control.I am setting the ImageUrl property of the image control during runtime in the ItemDatabound event of the Repeater control ( because image is being retrieved from the SQL database). I am setting the height and width property as well during runtime. Doing this I am able to see the resized image on the web page, but when I export this to MS Word, I am seeing the image in the word document with original dimensions. I need the word document to have the image in the same dimensions as I can see in the web page. Basically I am trying to generate the report in word format which would be exactly the same as that of the web page. Thanks, Avanika

      M Offline
      M Offline
      MudkiSekhon
      wrote on last edited by
      #2

      U can resize the images using classes in System.Drawing.Image Namespace here is an example which resizes the image if it has size larger than 600 width or height. U need to resize in proportion System.Drawing.Image tempImage = System.Drawing.Image.FromFile(strFilePath); //strFilePath is actual location of image if(tempImage.Width>600 || tempImage.Height>600 ) { int width,height; if(tempImage.Width>tempImage.Height) { width = 600; height = (tempImage.Height*600)/tempImage.Width; } else { height = 600; width = (tempImage.Width*600)/tempImage.Height; } System.Drawing.Image normalImage = new Bitmap(tempImage,width,height); normalImage.Save(strFileNewPath); // U r saving the file at new location } Regards, Sandy

      A 1 Reply Last reply
      0
      • M MudkiSekhon

        U can resize the images using classes in System.Drawing.Image Namespace here is an example which resizes the image if it has size larger than 600 width or height. U need to resize in proportion System.Drawing.Image tempImage = System.Drawing.Image.FromFile(strFilePath); //strFilePath is actual location of image if(tempImage.Width>600 || tempImage.Height>600 ) { int width,height; if(tempImage.Width>tempImage.Height) { width = 600; height = (tempImage.Height*600)/tempImage.Width; } else { height = 600; width = (tempImage.Width*600)/tempImage.Height; } System.Drawing.Image normalImage = new Bitmap(tempImage,width,height); normalImage.Save(strFileNewPath); // U r saving the file at new location } Regards, Sandy

        A Offline
        A Offline
        Avanika Gupta
        wrote on last edited by
        #3

        hi Sandy, thanks for the reply. I am fetching the image from the database at run time and then displaying it on the web page using image web server control. I have to export this web page to MS Word. Since the dimensions of the image are not the one that are required, so I have to resize the image. To do this i am setting the height and width of the image control. Doing this, Image dimensions on the web page gets changed but in the document it is still the same. Could you please help me to do this? Thanks, Avanika

        M 1 Reply Last reply
        0
        • A Avanika Gupta

          hi Sandy, thanks for the reply. I am fetching the image from the database at run time and then displaying it on the web page using image web server control. I have to export this web page to MS Word. Since the dimensions of the image are not the one that are required, so I have to resize the image. To do this i am setting the height and width of the image control. Doing this, Image dimensions on the web page gets changed but in the document it is still the same. Could you please help me to do this? Thanks, Avanika

          M Offline
          M Offline
          MudkiSekhon
          wrote on last edited by
          #4

          I don't know how to do this with images in databse but I think the efficient method would be to store images in the File system and store their url in the databse. Then u can manipulate them freely because there are lot of classes to do this. Regards, Sandy

          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