| | |
Retaining highest res. of a photo in upload?
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
Use this code:
And when saving use this:
This is GetEncoderInfo function:
ASP.NET Syntax (Toggle Plain Text)
Dim g As Graphics = Graphics.FromImage(YourBitmap) g.SmoothingMode = SmoothingMode.HighQuality g.InterpolationMode = InterpolationMode.HighQualityBicubic g.PixelOffsetMode = PixelOffsetMode.HighQuality
And when saving use this:
ASP.NET Syntax (Toggle Plain Text)
Dim myParams As EncoderParameters = New EncoderParameters(1) myParams.Param(0) = New EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 80) YourBitmap.Save(YourPath, GetEncoderInfo(MimeType), myParams)
This is GetEncoderInfo function:
ASP.NET Syntax (Toggle Plain Text)
Public Function GetEncoderInfo(ByVal MimeType As String) As ImageCodecInfo Dim j As Integer Dim encoders As ImageCodecInfo() encoders = ImageCodecInfo.GetImageEncoders() j = 0 Do While j < encoders.Length If encoders(j).MimeType = MimeType.Trim.Replace("pjpeg", "jpeg") Then Return encoders(j) End If j += 1 Loop Return Nothing End Function
Last edited by ManicCW; Apr 5th, 2007 at 4:01 am.
Wow- that was quick. I am a designer researching this for my programmer -- who is too slammed to research this. We are trying to keep the highest quality for uploaded photos, much like www.flickr.com does for it's members.
When you upload a 4000px by 2000px 5 meg image to (Flickr) it will compress to 1/2 or 2.5 meg and display at the appropriate aspect ratio for their site.
Our .Net app is compressing the photo file sizes much smaller, where as uploading a test photo to Flickr will sace at 58760 Kb our app. will save the same photo at 17240 Kb.
I will share your feedback with him. Thank you for taking the time to reply. It is greatly appreciated.
Rick
When you upload a 4000px by 2000px 5 meg image to (Flickr) it will compress to 1/2 or 2.5 meg and display at the appropriate aspect ratio for their site.
Our .Net app is compressing the photo file sizes much smaller, where as uploading a test photo to Flickr will sace at 58760 Kb our app. will save the same photo at 17240 Kb.
I will share your feedback with him. Thank you for taking the time to reply. It is greatly appreciated.
Rick
ManicCW
Here is the string we are using (C#)
System.Drawing.
Image image1 = System.Drawing.Image.FromFile(Server.MapPath(imgfilepath + actimgFilename));
System.Drawing.
Image smallimage = new Bitmap (imgNewWidth, imgNewHeight, image1.PixelFormat);
Graphics oGraphic = Graphics.FromImage(smallimage);
oGraphic.CompositingQuality =
CompositingQuality.HighQuality;
oGraphic.SmoothingMode =
SmoothingMode.HighQuality;
oGraphic.InterpolationMode =
InterpolationMode.HighQualityBicubic;
oGraphic.PixelOffsetMode =
PixelOffsetMode.HighQuality;
Rectangle oRectange = new Rectangle (0, 0, imgNewWidth, imgNewHeight);
oGraphic.DrawImage(image1, oRectange);
smallimage.Save(Server.MapPath(imgfilepath + newFilename), System.Drawing.Imaging.
ImageFormat.Jpeg);
Here is the string we are using (C#)
System.Drawing.
Image image1 = System.Drawing.Image.FromFile(Server.MapPath(imgfilepath + actimgFilename));
System.Drawing.
Image smallimage = new Bitmap (imgNewWidth, imgNewHeight, image1.PixelFormat);
Graphics oGraphic = Graphics.FromImage(smallimage);
oGraphic.CompositingQuality =
CompositingQuality.HighQuality;
oGraphic.SmoothingMode =
SmoothingMode.HighQuality;
oGraphic.InterpolationMode =
InterpolationMode.HighQualityBicubic;
oGraphic.PixelOffsetMode =
PixelOffsetMode.HighQuality;
Rectangle oRectange = new Rectangle (0, 0, imgNewWidth, imgNewHeight);
oGraphic.DrawImage(image1, oRectange);
smallimage.Save(Server.MapPath(imgfilepath + newFilename), System.Drawing.Imaging.
ImageFormat.Jpeg);
![]() |
Similar Threads
- photo upload editor clone (Visual Basic 4 / 5 / 6)
- hompage resets to res://hsnyc.dll/index.html#37049 (Viruses, Spyware and other Nasties)
- Virus, Adware, or just explorer causing malfunctions-res://mshp.dll/http_404.htm (Viruses, Spyware and other Nasties)
Other Threads in the ASP.NET Forum
- Previous Thread: How to create a login page using ASp.net 2.0 c#
- Next Thread: An unhandled exception of type 'System.Net.Sockets.SocketException' error
| Thread Tools | Search this Thread |
.net 2.0 3.5 ajax alltypeofvideos appliances asp asp.net beginner box browser businesslogiclayer button c# cac checkbox class commonfunctions compatible content contenttype control countryselector courier dataaccesslayer database datagrid datagridview datalist deployment development dgv dialog dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv formview gridview gudi iis javascript list listbox login menu microsoft mouse mssql nameisnotdeclared news novell numerical opera order panelmasterpagebuttoncontrols problem radio ratings redirect registration relationaldatabases reportemail schoolproject search security serializesmo.table sessionvariables silverlight smoobjects software sql sql-server sqlserver2005 ssl tracking treeview validatedate validation vb.net videos vista visual-studio visualstudio vs2008 web webapplications webarchitecture webdevelopment webprogramming webservice wizard xsl





