"Read in the image filename to create a thumbnail of
Dim imageUrl As String = Request.QueryString("img")
"Read in the width and height
Dim imageHeight As Integer = Request.QueryString("h")
Dim imageWidth As Integer = Request.QueryString("w")
"Make sure that the image URL doesn"t contain any /"s or \"s
If imageUrl.IndexOf("/") >= 0 Or imageUrl.IndexOf("\") >= 0 Then
"We found a / or \
Response.End()
End If
"Add on the appropriate directory
imageUrl = "mypics/" & imageUrl
Dim fullSizeImg As System.Drawing.Image
fullSizeImg = System.Drawing.Image.FromFile(Server.MapPath(imageUrl))
"Do we need to create a thumbnail?
Response.ContentType = "image/jpg"
If imageHeight > 0 And imageWidth > 0 Then
Dim dummyCallBack As System.Drawing.Image.GetThumbnailImageAbort
dummyCallBack = New System.Drawing.Image.GetThumbnailImageAbort(AddressOf ThumbnailCallback)
Dim thumbNailImg As System.Drawing.Image
thumbNailImg = fullSizeImg.GetThumbnailImage(imageWidth, imageHeight, dummyCallBack, IntPtr.Zero)
fullSizeImg.Save(Response.OutputStream, ImageFormat.Gif)
Else
fullSizeImg.Save(Response.OutputStream, ImageFormat.Gif)
End If
|