Google Answers Logo
View Question
 
Q: ASP -- resizing access ole object on the fly ( No Answer,   2 Comments )
Question  
Subject: ASP -- resizing access ole object on the fly
Category: Computers > Programming
Asked by: jinlynn-ga
List Price: $30.00
Posted: 15 Sep 2004 14:26 PDT
Expires: 15 Oct 2004 14:26 PDT
Question ID: 401699
A little background: I have images stored in an Access database as OLE
objects. I want to be able to reduce the image size so as to reduce
load time when displaying these images in a webpage. I have two asp
scripts, one which displays the binary image and one which reduces
image size of regular image files. But I don't know how I can combine
the two to reduce the size of the embedded image.

Here is script 1 (display database image):
<%
'Step 1: Read in the vin from the querystring
Dim ivinID
ivinID = Request.QueryString("vinnum")
'Step 2: grab the picture from the database
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rs 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query to query the database 
'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
Server.MapPath("database/carshowroom.mdb")
'Create an ADO recordset object
Set rs = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT PHOTO1 FROM tblVEHICLES WHERE VIN LIKE " & "'" & ivinID & "'"
'Open the recordset with the SQL query 
rs.Open strSQL, adoCon 
'Step 3: Set the ContentType to image/jpeg
Response.Clear
Response.ContentType = "image/jpg"
'Step 4: Use Response.BinaryWrite to output the image
Response.BinaryWrite rs("photo1")
'Clean up...
rs.Close 
adoCon.Close
Set rs = NothingadoCon.Close
Set adoConn = Nothing
%>

Here is script 2 (resizes images):
<script language="VB" runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)

Dim orginalimg, thumb As System.Drawing.Image
Dim FileName As String
Dim inp As New IntPtr()
Dim width, height As Integer
Dim rootpath As String
rootpath = Server.MapPath("/") ' Get Root Application Folder
FileName = rootpath & Request.QueryString("FileName") ' Root Folder + FileName
Try
orginalimg = orginalimg.FromFile(FileName) ' Fetch User Filename
Catch
orginalimg = orginalimg.FromFile(rootpath & "error.gif") ' Fetch error.gif
End Try
' Get width using QueryString.
If Request.QueryString("width") = Nothing Then
width = orginalimg.Width ' Use Orginal Width. 
ElseIf Request.QueryString("width") = 0 Then ' Assign default width of 100.
width = 100
Else
width = Request.QueryString("width") ' Use User Specified width.
End If
' Get height using QueryString.
If Request.QueryString("height") = Nothing Then
height = orginalimg.Height ' Use Orginal Height.
ElseIf Request.QueryString("height") = 0 Then ' Assign default height of 100.
height = 100
Else
height = Request.QueryString("height") ' Use User Specified height.
End If
thumb = orginalimg.GetThumbnailImage(width, height, Nothing, inp)
' Sending Response JPEG type to the browser. 
Response.ContentType = "image/jpeg"
thumb.Save(Response.OutputStream, Imaging.ImageFormat.Jpeg)
' Disposing the objects.
orginalimg.Dispose()
thumb.Dispose()
End Sub
</script>

Here is what I am using to display my database photo : <img
src=getphoto1.asp?vinnum=$VIN->value">

Is there a way I can use the second script when displaying the photo? 
If so, how?  For example, I tried using the above call as the filename
for the
second script, but that doesn't work (<img
src=thumbphoto.aspx?filename=getphoto1.asp?vinnum= $VIN->value">).  Is
there a script which will allow me to display resized images?

Thank you for any advice!
Answer  
There is no answer at this time.

Comments  
Subject: Re: ASP -- resizing access ole object on the fly
From: nick_name-ga on 16 Sep 2004 17:04 PDT
 
Wouldn't your webpage load faster if you stored the path (or URL) of
the image in the database as opposed to the actual image? I don't
understand why you would want the actual image stored as an OLE
object?
Subject: Re: ASP -- resizing access ole object on the fly
From: jinlynn-ga on 16 Sep 2004 19:13 PDT
 
That was my preference -- but the webhost wouldn't allow my upload
script to upload files to the directory.  I know it will bloat the
database, but at least there won't be more than 12 records at a given
time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy