ASPJPEG Help

A

audiopro

I am having some trouble here, and my brain is running on empty. I am
not an expert ASP coder, so forgive me for what is probably sloppy
code, and not the best...

At any rate, I have created the following code to randomly select an
image under a random set of folders from my gallery. Once that is done,
I call sendbinary.asp which should size and display the image... Here
is my code. Problem is, I am getting a good ole red X. It looks like it
is passing things okay, but still not working.

The URL for test is http://earth.sitepros.net/test/rndimage.asp

rndimage.asp

------------------------
<%

Const ImagesRoot = "images"
Const ThumbsFolder = "__thumbs"

' Get List of Subfolders under ImagesRoot
Set fsoFolder = CreateObject("Scripting.FileSystemObject")

Set FolderRoot =
fsoFolder.GetFolder(Server.MapPath(ImagesRoot))

Set FolderSubs = FolderRoot.subfolders

' Get a Random Folder Number from List
randomize
RndFolderNum = Int(FolderSubs.count * Rnd)

' Associate Folder name based on Random Number Results
For Each objFolder in FolderSubs
If intFileLooper = RndFolderNum Then
' Get a "handle" on the appropriate file
Set objFolderToUse = objFolder
Exit For
End If
intFileLooper = intFileLooper + 1
Next

'Clean up Above Variables
Set fsoFolder = Nothing
Set FolderRoot = Nothing
Set FolderSubs = Nothing
Set RndFolderNum = Nothing


' Build Complete Virtual Path to Random Folder
objFolderToUsePath = (ImagesRoot & "/" & objFolderToUse.name & "/" &
ThumbsFolder &"/")

' Get a List of Image Files from Folders
Set fsoFile = Server.CreateObject("Scripting.FileSystemObject")
Set objFolderObject =
fsoFile.GetFolder(Server.MapPath(objFolderToUsePath))

Set objFileCollection = objFolderObject.Files

' Get a Random File Number from List
randomize
intFileNumberToUse = Int(objFileCollection.Count * Rnd) + 1

' Associate File name based on Random Number Results
intFileLooper = 1
For Each objFile in objFileCollection
If intFileLooper = intFileNumberToUse Then
' Get a "handle" on the appropriate file
Set objImageFileToUse = objFile
Exit For
End If
intFileLooper = intFileLooper + 1
Next

' Clean up Above Variables
Set fsoFile = Nothing
Set objFolderObject = Nothing
Set objFileCollection = Nothing

' Build our img src tag text
strImageSrcText = objFolderToUsePath & objImageFileToUse.Name

%>


<!- Display The Image ->
<img src ="sendbinary.asp?path=<%= strImageSrcText %>&width=125">


<%

'Clean up Remaining Variables
Set objFolderToUse = Nothing
Set objFolderToUsePath = Nothing
Set objImageFileToUse = Nothing
Set strImageSrcText = Nothing

%>

sendbinary.asp
------------------------
<%
Response.Expires = 0
' create instance of AspJpeg
Set Jpeg = Server.CreateObject("Persits.Jpeg")

' Open source file
Jpeg.Open( Request("path") )

' Set new height and width
Jpeg.Width = Request("Width")
Jpeg.Height = Jpeg.OriginalHeight * Jpeg.Width / Jpeg.OriginalWidth

' Perform resizing and
' send resultant image to client browser
Jpeg.SendBinary

%>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,828
Latest member
LauraCastr

Latest Threads

Top