I have an .aspx page from which users can upload an image. After a
file is uploaded, I also save a 60x60 pixel thumbnail of that image.
Works great.
What I can't seem to do is save a CROPPED thumbnail of that image that
does not stretch the image. Does anyone have code (VB please -- no
C#) that can do that?
Help would be appreciated. Here's what I have:
Dim imgFullSize, imgThumbnail As System.Drawing.Image
imgFullSize = System.Drawing.Image.FromFile(strBasePath &
strFinalFileName)
Response.ContentType = "image/jpeg"
Dim objDummyCallBack As System.Drawing.Image.GetThumbnailImageAbort =
New System.Drawing.Image.GetThumbnailImageAbort( AddressOf
ThumbnailCallBack )
imgThumbnail = imgFullSize.GetThumbnailImage(60, 60, objDummyCallBack,
IntPtr.Zero)
do while system.io.file.exists(strProposedFilename) = true
RandX = CLng(Int((9999999999 * Rnd()) + 1))
pos = strProposedFilename.lastindexof(".")
strFilenameExtension = strProposedFilename.substring(pos)
strProposedFilename = strProposedFilename.substring(0, pos) & RandX &
strFilenameExtension
loop
dim strFinalThumbnailFileName = strProposedFilename
s1= strFinalThumbnailFileName
pos=s1.lastindexof("\") +1
s2=s1.substring(pos)
strFinalThumbnailFileName = s2
imgThumbnail.Save(strBasePath & strFinalThumbnailFileName,
System.Drawing.Imaging.ImageFormat.Jpeg)