Current location: Hot Scripts Forums » Programming Languages » ASP » Please help -- need to resize Access OLE image


Please help -- need to resize Access OLE image

Reply
  #1 (permalink)  
Old 09-13-04, 11:29 PM
jinlynn jinlynn is offline
New Member
 
Join Date: Sep 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Please help -- need to resize Access OLE image

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? 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">).

Thank you for any advice!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
searching image nurqeen PHP 4 07-09-05 10:35 AM
how to draw an image inside a table? davidklonski HTML/XHTML/XML 2 07-06-04 11:27 AM
will pay. php script needed. upload, resize, & email jamjammo Script Requests 4 02-29-04 09:30 PM
Help with image resize mdhall PHP 3 02-25-04 02:53 AM
Retrieve Image from an Access Db Paulgood30 ASP.NET 1 11-15-03 11:41 AM


All times are GMT -5. The time now is 09:13 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.