ASPJPEG Help

Discussion in 'ASP General' started by audiopro@gmail.com, Oct 6, 2005.

  1. Guest

    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

    %>
    , Oct 6, 2005
    #1
    1. Advertising

  2. Guest

    Well I figured out what my problem was. I was using a virtual path, not
    a complete physical path. So the code works now! I have an image
    rotator on my site that pulls random images from random dirs.

    Here is a link to my site, as well the code for the image rotator.

    http://weblog.sitepros.net/journal_comments.asp?JournalID=79
    , Oct 7, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?dHJlbGxvdzQyMg==?=

    HELP! HELP! HELP! Opening Web Application Project Error

    =?Utf-8?B?dHJlbGxvdzQyMg==?=, Feb 20, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    766
    =?Utf-8?B?dHJlbGxvdzQyMg==?=
    Feb 20, 2004
  2. Tony
    Replies:
    3
    Views:
    3,356
  3. Tony
    Replies:
    0
    Views:
    523
  4. Tony

    ASPJPEG in vb.net ???

    Tony, Apr 26, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    2,341
    Kevin Spencer
    Apr 26, 2005
  5. Christopher Brandsdal

    AspJpeg

    Christopher Brandsdal, Jul 31, 2003, in forum: ASP General
    Replies:
    0
    Views:
    188
    Christopher Brandsdal
    Jul 31, 2003
Loading...

Share This Page