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