Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help:getting size of picture using asp script

Status
Not open for further replies.

bugeditor

Technical User
Oct 9, 2001
44
0
0
IN
Hi,
can anybody help me with a snippet,how to determine the ht and width of pictutre on serverside script in an asp page

Thanks & redards
 
Here is one of my functions, hope you can extract the relevant bits you require. Look-up help on LoadPicture for more info

'Get dimensions of picture and limit them (NB pngs don't work ...doh)
Function PictureLimit(byVal strPath, byRef strWidth, byRef strHeight)

Dim strExt, colSplit, objPict, intW, intH, strDebug

If (FileExists(strPath)) Then
colSplit = split(strPath, ".")
strExt = colSplit(UBound(colSplit))
Select Case Lcase(strExt)
Case "bmp", "ico", "rle", "wmf", "emf", "gif", "jpg"
'writedebug Path='" & strPath & "'"
Set objPict = LoadPicture(strPath)
intW = Round(objPict.Width/26.5) + 1
intH = Round(objPict.Height/26.5) + 1
Set objPict = Nothing


'strDebug = "Path='" & strPath & "'" & vbTab & "Width=" & strWidth & " Height=" & strHeight & vbTab & "RawWidth=" & intW & " RawHeight=" & intH
' Check if sizes are within bounds, if the are then don't limit them
' Limit height by default
If (IsNumeric(strHeight)) Then
' Calculate new size if required
if (CInt(strHeight)<intH) Then
intW = Round(intW * CInt(strHeight) / intH)
intH = CInt(strHeight)
Else
strHeight = &quot;&quot;
End If

' Extra width limiting
If (IsNumeric(strWidth)) Then
If (intW >= CInt(strWidth)) Then
strHeight = Round(intH * CInt(strWidth) / intW)
End If
End if
strWidth = &quot;&quot;
Else
If (intW < CInt(strWidth)) Then strWidth = &quot;&quot;
End if
PictureLimit = &quot;&quot;
If (strWidth<>&quot;&quot;) Then PictureLimit = PictureLimit & &quot; WIDTH=&quot; & strWidth & &quot;&quot;
If (strHeight<>&quot;&quot;) Then PictureLimit = PictureLimit & &quot; HEIGHT=&quot; & strHeight & &quot;&quot;
'strDebug = strDebug & vbTab & &quot;Limit='&quot; & PictureLimit & &quot;'&quot;
'writeinfo strDebug
'response.end
End Select
End If

End Function


 
ya ya..I got from msdn help.
I done it works fine with windows...But on linux hosting asp chillisoft server it gives an error
at line:
set myPic = LoadPicture(Path)

error msg is:

Path:&quot;/u238/spain92/viewpictures/naturepictures/boat.jpg&quot;

Microsoft VBScript runtime error '800a000d'

Type mismatch: '[undefined]'

/viewpictures/slideshow.asp, line 31


debug response.write Path..it is giving correct path
but error msg at that line

any idea

regards
 
Hi,
I am using loadpicture function to calculate ht and width at serverside

the code is as below

It works fine with windows as per the following code
set myPic = LoadPicture(&quot;c:\MyFolder\mygif.gif&quot;)

But,gives type mismatch with linux Hosting chiliisoft asp webserver
as per the following code--path is correct..but error

myPic = LoadPicture(&quot;/MyFolder/mygif.gif&quot;)

any hint to find problem is greatly appreciated

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top