I have very basic knowledge of ASP.net. I am using following script to resize and image, but the problem is it increases the disk volume of resized image to almost 4 times or original image.
Example: Original Image: 1024 x 769px and Disk space: 135 KB
Resized Image: 600 x 380px and Disk space: 825KB
Notice resized image becomes 825KB.
dim g1 as System.Drawing.Image = System.Drawing.Image.FromFile(txtGetImage)
dim thisFormat1=g1.rawformat
'#600
height = g1.Height / (g1.Width / 600)
dim imgOutput1 as New Bitmap(g1, 600, height)
imgOutput1.Save(txtMedium)
g1.dispose()
imgOutput1.dispose()
I have very basic knowledge of ASP.net so did not quite understand what you referred. I just need to resize images with minimum loss of quality and resized image can be in any format (gif, jpeg, jpg, png etc etc)
Right, so you are loading the compressed file and saving a bitmap with no compression. So of course the file is larger. Now, even with compression, you might not do that great – the JPEG compression that image manipulation programs can make is worlds ahead of what the BCL makes.
That’s the only way I know of that would keep the file weight the same while having the rendered file dimensions different.
Not that I’d recommend doing it, but I’ve seen it done often enough. It seems there are plenty that either don’t know how or can’t be bothered to use an application to optimize their image files.
Yes, Don’t resize the file. Specify the dimensions you want in the mark-up and it will render at those dimensions while retaining the original file weight.
I was going to mention System.Drawing.Graphics but webcosmo already did in his link. Using it you can use InterpolationMode and SmoothingMode to allow for a higher quality result.
jpeg, jpj,… are already compressed files, so if you take a compressed file and then render it as a bitmap file (which is not compressed), the size will be different. So you have to take that into consideration when dealing with images