|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Can someone tell me how to generate thumbnnails in ASP.NET using C#. I want the thumbnail to be generated of particular width and height of the photo uploaded of anysize.
Can anybody help me in doing that? |
|
#2
|
|||
|
|||
|
try looking at
System.Drawing.Drawing2D System.Drawing.Imaging this article may also help: http://www.eggheadcafe.com/articles/20030515.asp
__________________
Tivo Codes, Hacking the Tivo, and Adding a Second Drive to Your Tivo. All this information at www.TivoSpy.com ! |
|
#3
|
|||
|
|||
|
Keep Original Image Proprotion
Const THUMB_WIDER As Int32 = 90 ' can be dynamic value with parameters
Const COMPRESSION_QUALITY As Int32 = 90 ' can be dynamic Public Sub SaveThumbSize(ByVal sSource As String, ByVal sDestination As String) imgSrc = New Bitmap(sSource) Dim ratio As Double If imgSrc.Width > imgSrc.Height Then ratio = THUMB_WIDER / imgSrc.Width imgDstW = THUMB_WIDER imgDstH = CInt(imgSrc.Height * ratio) Else ratio = THUMB_WIDER / imgSrc.Height imgDstH = THUMB_WIDER imgDstW = CInt(imgSrc.Width * ratio) End If imgDst = New Bitmap(imgSrc, imgDstW, imgDstH) SaveImage(imgDst, sDestination, COMPRESSION_QUALITY) imgDst.Dispose() imgSrc.Dispose() imgDst = Nothing imgSrc = Nothing End Sub Public Sub SaveImage(ByRef img As Image, ByVal dest As String, ByVal compression As Integer) Dim EncoderParams As New EncoderParameters(1) Try EncoderParams.Param(0) = New EncoderParameter(Encoder.Quality, compression) img.Save(dest, GetEncoderInfo, EncoderParams) Catch ex As Exception 'img.Save(dest) End Try EncoderParams.Dispose() EncoderParams = Nothing End Sub Private Function GetEncoderInfo() As ImageCodecInfo Dim encoderReturn As ImageCodecInfo = Nothing Dim encoders As ImageCodecInfo() = ImageCodecInfo.GetImageEncoders Dim encoder As ImageCodecInfo For Each encoder In encoders If encoder.MimeType = "image/jpeg" Then encoderReturn = encoder End If Next encoders = Nothing Return encoderReturn End Function ======================== http://www.busyphoto.com http://mobile.busyphoto.com ======================== |
|
#4
|
|||
|
|||
|
Quote:
This can be done by using an object of System.Drawing.Image |
![]() |
| Viewing: Dev Articles Community Forums > Programming > .NET Development > Thumbnail Generation in ASP.NET using C# |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|