I want my users to be able to click on a thumbnail of an image and allow them to print it out. All of the images are in a Tiff format. I thought of using the Imaging program but I was told to bring it up in a browser. Is this possible? Thanks in advance.
I was able to figure out how to get the image into a data list then when the user clicks on the thumbnail image the image come up. If any anyone needs the code it's a modified version found at:
'CreateDirectory used to create the folder for thumbnail images
Private Function CreateDirectory(ByVal FullPath As String) As Boolean
Dim objDI As New DirectoryInfo(FullPath)
Try
objDI.Create()
Return True
Catch
Return False
End Try
End Function
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
makeThumbnail(myfile)
End Sub
Private Sub makeThumbnail(ByVal filename As String)
Dim s As String
Dim html As String
'loop through folder to get all immages
For Each s In Directory.GetFiles(filename, "*.tif"
Dim g As System.Drawing.Image = System.Drawing.Image.FromFile(s)
Dim thisFormat = g.RawFormat
Dim thumbSize As New Size()
Dim myRoot As String = "C:\thumbnails"
Dim root, file As String
root = myRoot & filename
file = Path.GetFileName(s)
CreateDirectory(root)
thumbSize = newThumbSize(g.Width, g.Height)
Dim imgOutput As New Bitmap(g, thumbSize.Width, thumbSize.Height)
If thisFormat.Equals(System.Drawing.Imaging.ImageFormat.Gif) Then
Response.ContentType = "image/gif"
Else
Response.ContentType = "image/jpeg"
End If
'set the location of thumbnail images
Dim MyLocation As String = root & file
imgOutput.Save(MyLocation, Imaging.ImageFormat.Jpeg)
imgOutput.Dispose()
g.Dispose()
'ImageHome--location the original image resides
Dim ImageHome As String = "C:\Images" & s
html = "<a href=""" & ImageHome & """>" & "<img src=""" & MyLocation & """" & _
"height=""" & thumbSize.Height & """ width=""" & thumbSize.Width & """>" & "</a>"
pics.Add(html)
Next
dlPictures.DataSource = pics
dlPictures.DataBind()
End Sub
Private Function newThumbSize(ByVal currentwidth As Integer, ByVal currentheight As Integer)
' Calculate the Size of the New image
Dim tempMultiplier As Double
If currentwidth > 100 Then ' portrait
tempMultiplier = 100 / currentwidth
Else
tempMultiplier = 1
End If
Dim NewSize As New Size(CInt(currentwidth * tempMultiplier), CInt(currentheight * tempMultiplier))
Return NewSize
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.