related sites: <FREE Help> <ASP> <Asp.net> <worldwide> feedback: <lovethat> <hatethat> <thanks> <credits> <contact us>
HTTP Headers <Next>
X-Sender: matthew@mail.tangent.com.au Date: Thu, 23 Apr 1998 02:32:27 +1000 From: "Matthew R. Proctor" <matthew@wolfven.com> Subject: [asp advanced] GIF/JPG Dimensions
Hi All,
Does anyone know how to dynamically retrieve the HEIGHT and WIDTH of an GIF/JPG? I have a number of images, their locations stored in a database, but I want to be able to retrieve their dimensions so that I can speed up display, and figure out the most appropriate place to display them.
Any ideas? Matthew --- Matthew R. Proctor Imagineering Technology Melbourne, Australia
From: David Wihl <wihl@softartisans.com> Subject: RE: [asp advanced] GIF/JPG Dimensions Date: Wed, 22 Apr 1998 12:50:04 -0400
This works for GIF's only, from the Software Artisans' knowledge base (http://support.softartisans.com). It does *not* use SA-FileUp :)
Software Artisans Knowledge Base Product: SAFILEUP Version: 2.0.1 Title: HOWTO: Resizing a GIF image for display Description: SA-FileUp is commonly used to upload or download images files. Many customers would like to resize the image upon upload or download. Corrective Action: This script was supplied by an astute customer, Magnus Lindbergh of CreateIT web agency in Sweden.
Thanks Magnus! It assumes that the image has been uploaded to a database, but could easily be adapted when the image is uploaded to a file. For use with a file, use ASP's Scripting.FileSystemObject to read the first few bytes of the image.
<% SQL = "SELECT BLOB " SQL = SQL & "FROM objectIMAGE WHERE (((objectIMAGE.imageID)=" & Request.QueryString("imageID") & "));" Set Connection = Server.CreateObject("ADODB.Connection") Set RS = Server.CreateObject("ADODB.RecordSet") RS.Open SQL, "DSN=DN", 3, 3 Dim BitSet ReDim BitSet (10) For I = 0 to 10 BitSet(I) = RS.Fields("BLOB").GetChunk(1) Next ' Calculate GIF width & height using bit 6-9 width = (256 * AscB(BitSet(7))) + AscB(BitSet(6)) height = (256 * AscB(BitSet(9))) + AscB(BitSet(8)) ' Max width / height MaxWidth = 300 MaxHeight = 200 ' Resize the image iWidth = width iHeight = height If iWidth > MaxWidth Then iHeight = iHeight * maxWidth / iWidth iWidth = maxWidth End If If iHeight > MaxHeight Then iWidth = iWidth * maxHeight / iHeight iHeight = maxHeight End If ' Store Values in Session variables Session("sWidth") = iWidth Session("sHeight") = iHeight %> This script must be executed before doing the binarywrite. This script will be called from the .asp page after executing the above script. Using a HTML TAG like:
<img src="resize_gif.asp?imageID=<%=request.querystring("objectID")%>" width="<%=Cint(Session("sWidth"))%>" height="<%=Cint(Session("sHeight"))%>">
Note the use of Session("sWidth") & Session("sHeight"), which are calculated in the first script.
resize_gif.asp
<% MaxSize = 700000 Response.Expires = 0 Response.Buffer = TRUE Response.Clear Response.ContentType="image/gif" Set Connection = Server.CreateObject("ADODB.Connection") Connection.Open "DSN=DN" SQLB = "SELECT BLOB FROM objectIMAGE WHERE imageID =" SQLB = SQLB & Request.QueryString("imageID") Set rsBlob = Connection.Execute(SQLB) Response.BinaryWrite rsBlob("BLOB").getChunk(MaxSize) Response.End %> Created: 4/17/98 Last Update: Article Id: 21 -David
From: Richard Birkby <RBirkby@3s.co.uk> Subject: RE: [asp advanced] GIF/JPG Dimensions Date: Wed, 22 Apr 1998 18:33:02 +0100
VBScript has a LoadPicture function, which will return a StdPicture object. This should have Height and Width methods, however they are in OLE_HIMETRIC units.
Now in VB5, I would use ScaleX and ScaleY to convert these. Anyone know how to convert them in VBS?
Richard