Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

display image 1

Status
Not open for further replies.

chicdog

Programmer
Feb 28, 2002
84
US
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.

Chikey
 
The one I changed is that I want the thumbnails I create stored in a data list along with the actual path of the full size image.

Chikey
 
Chikey: I just posted a thread regarding thumbnails, etc...

Not sure if you need any special additions for printing since a simple right click on the mouse will send it to the printer.
 
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:

Here is what I did.

'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 = &quot;<a href=&quot;&quot;&quot; & ImageHome & &quot;&quot;&quot;>&quot; & &quot;<img src=&quot;&quot;&quot; & MyLocation & &quot;&quot;&quot;&quot; & _
&quot;height=&quot;&quot;&quot; & thumbSize.Height & &quot;&quot;&quot; width=&quot;&quot;&quot; & thumbSize.Width & &quot;&quot;&quot;>&quot; & &quot;</a>&quot;

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

End Function
 
A star for you for solving a problem that i hadn't got around to stressing myself over! Thank you... Now to put the family photos on the web....

:)

Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top