GetFileDimensions

The GetFileDimensions function gets an information about image file and dimensions of the picture.

GetFileDimensions sFileName,iX,iY [,aPalette]

Parameters

sFileName
Specifies the name of the file to get info about.
You can specify the binary safearray instead of file name string. In this case the necessary day will be get from that array. Using FileStart and FileSize properties, you can set where the image data are located in the array.
Other ShotGraph object can also be specified instead of file name. In this case the information about active imagespace of that object will be returned.

iX
Variable accepting horizontal size of the image in pixels

iY
Variable accepting vertical size of the image in pixels

aPalette
Optional. On return, contains two dimensional array with image palette, if the image is a GIF image or paletted BMP image. The first index of array is the color number. The second index of array (0..2) is accordingly red, green, and blue color component. The lower bound of array is always zero.

Return value

The possible return values are:

Remarks

This function analizes file content and returns both horizontal and vertical sizes of the image. It can be used in your Web applications which need to know image sizes before sending 'IMG SRC=... width=... height=...' tag to the client.
The function checks whether the image file is a vector metafile image only if the AdvancedCheck property is set to True.
The GetFileDimensions sets the Resolution property if image has been recognized as Jpeg, Png or Tiff. This feature allows to check not only dimensions of images but their resolutions too.

Possible data types for 'sFileName' parameter
Data typeMeans
StringPath to file. The image will be read from that file.
SafearrayImage in safearray. The image will be read from safearray.
ShotGraph objectThe image will be read from active imagespace of other ShotGraph object.

Example

<%
filename="c:\temp\testfile.gif"
set obj=Server.CreateObject("shotgraph.image")

Select Case obj.GetFileDimensions(filename,x,y)
Case 1
	out_str="GIF image: " & x & "x" & y
Case 2
	out_str="JPEG image: " & x & "x" & y
Case 3
	out_str="BMP image: " & x & "x" & y
Case 5
	out_str="PNG image: " & x & "x" & y
Case 0
	out_str="Unknown file format"
End Select
%>
<BODY>
<H2>Information about file <% =filename %></H2>
<% =out_str %>
</BODY>