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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Image editing w/ remote files in ASP.NET

Status
Not open for further replies.

qwert231

Programmer
Sep 4, 2001
756
US
Okay... so here's what I want to do. I want the user to be able to select from a list of images (a list which will be generated from a database of stored images) and see a thumbnail of that image. I can easily create a thumbnail, save it as a temp file and show that file, if the original is local. However, the image path is saved in the database as a UNC, and from my webserver, they are remote. I cannot put them local... Hmm... can I copy the file via my code to a local folder and then work on it... hmmm...
 
Can't do it that way either. Is there a way I can call a VBScript script that will copy the file local to a temp file? I can come up with the VBScript, but I can't think of how to get .Net to run it, then do the .Net stuff... If you've got a thread on that, drop me a line. Thanks.
 
OK this may be no help at all but... I did this and I think I did it slightly different to you.
I stored all my images in a database in the form of blobs (thumbs and orig). I then made a page to binary write the image information to the response stream (of course you need to put the header info in). Then to call the images is quite simple. Your image tag looks something like
<img src=&quot;binWriter.aspx?img=ImageNameOrID&quot;>
This way you have no need to actually write the images to a temp file or deal with paths.
 
Hmm... I cannot change the way I store the images... but you gave me an idea. I can put the binWriter page on the server that stores the images, so they will be local, I have some code that will write binary data of the thumbnail of the file, then all I have to do is call that page over... I think it will work. Let me see what I can come up with, in the mean time, let me give you something to talk about. Carrot Top is neither a carrot, or the top. Discuss.
 
Color of a carrot and the top of subjects body.

Go carrot tops We shall conquer all. That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
Okay, here is what I did. I created a page that does nothing but return an image content... I have my page call this page like this: img1.ImageUrl = &quot;testThmb.aspx?FileName=&quot; & subjList.SelectedItem.Value.Trim
(img1 is the name of the image control on the page.)

Can anybody help me with this?

Here is the page code:
Code:
<%@ Page Language=&quot;vb&quot; AutoEventWireup=&quot;false&quot;%>
<%@ Import Namespace=System.Drawing %>
<%@ Import Namespace=System %>
<%@ Import Namespace=System.Web %>
<script language=&quot;vb&quot; runat=&quot;server&quot;>
 Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)

  Dim orginalimg, thumb As System.Drawing.Image
  Dim inp As New IntPtr()
  Dim width, height As Integer
  Dim rootpath, srcImg As String

  'srcImg = Request.QueryString(&quot;FileName&quot;)
  'rootpath = Server.MapPath(srcImg.Replace(&quot;\\Dell2400\Images_03&quot;, &quot;C:&quot;)) ' Get the path to the image.
  rootpath = Server.MapPath(&quot;/secure/images/&quot;) & &quot;map3.jpg&quot;
  Try
   orginalimg = orginalimg.FromFile(rootpath) ' Fetch User Filename
  Catch
   'orginalimg = orginalimg.FromFile(rootpath & &quot;error.gif&quot;) ' Fetch error.gif
  End Try

  ' Get width.
  width = orginalimg.Width / 5 ' Use Orginal Width. 
  ' Get height using QueryString.
  height = orginalimg.Height / 5 ' Use Orginal Height.
  'Make Thumb.
  thumb = orginalimg.GetThumbnailImage(width, height, Nothing, inp)
  ' Sending Response JPEG type to the browser. 
  Response.ContentType = &quot;image/jpeg&quot;
  thumb.Save(Response.OutputStream, Imaging.ImageFormat.Jpeg)
  ' Disposing the objects.
  orginalimg.Dispose()
  thumb.Dispose()

 End Sub
</script>
<html>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top