Results 1 to 8 of 8

Thread: asp.net:save pictures from other page [RESOLVED]

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Minnesota
    Posts
    830

    asp.net:save pictures from other page [RESOLVED]

    We have an old site that we can't get into anymore and want to save the images for our new site. Yes, we can do a right-click and save as but this could take some time. We have the full url path stored in a database and can get access to that. I am just wondering if anyone knows of any asp.net code that will allow use to quickly save these.

    I originally found some code by Karl Moore that does a nice job of viewing an image as a thumbnail but also only works if file is on the server. (posting his code below)

    I guess either way would work if I can get to work.

    Thanks in advance.

    Karls code
    VB Code:
    1. <%
    2. ' Initialize objects
    3. Dim objImage, objThumbnail As System.Drawing.Image
    4. Dim strServerPath, strFilename As String
    5. Dim shtWidth, shtHeight As Short    
    6. ' Get image folder path on server - use "\" string if root
    7. strServerPath = Server.MapPath("images\")
    8. ' Retrieve name of file to resize from query string
    9. strFilename = strServerPath & Request.QueryString("filename")
    10.  
    11.  
    12. ' Retrieve file, or error.gif if not available
    13. Try
    14.     objImage = objImage.FromFile(strFilename)
    15. Catch
    16.     objImage = objImage.FromFile(strServerPath & "error.gif")
    17. End Try
    18. ' Retrieve width from query string
    19. If Request.QueryString("width") = Nothing Then
    20.     shtWidth = objImage.Width
    21. ElseIf Request.QueryString("width") < 1 Then
    22.     shtWidth = 100
    23. Else
    24.     shtWidth = Request.QueryString("width")
    25. End If
    26. ' Work out a proportionate height from width
    27. shtHeight = objImage.Height / (objImage.Width / shtWidth)
    28. ' Create thumbnail
    29. objThumbnail = objImage.GetThumbnailImage(shtWidth, _
    30.   shtHeight, Nothing, System.IntPtr.Zero)
    31. ' Send down to client
    32. Response.ContentType = "image/jpeg"
    33. objThumbnail.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg)
    34. ' Tidy up
    35. objImage.Dispose()
    36. objThumbnail.Dispose()
    37. %>

    To call this:
    http://www.url.com/viewthumbnail.asp....jpg&width=250
    Last edited by lleemon; Jun 18th, 2004 at 03:23 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width